Originally Posted by
kmdv
C-strings are pure arrays while std::strings are object-oriented, what makes them two totally different interfaces.
Yes but that is a very superficial syntactical difference, IMO, and I am perfectly comfortable with both "interface styles", so that is more or less a non-issue (for me, and probably lots of other people too):
Code:
doSomething(myArray, param); // array function syntax.
myObject.doSomething(param); // OO syntax, OMG.
std:
w)string should always be prefered, unless there is a specific reason.
Agreed, and I said that explicitly. "Specific reason" to me is usually: low level C API making it impossible to not use a c-string at various points, in which case I am not going to turn a char* returned into a std:string then turn it back into a c_str() as it is passed around, that is like driving in concentric circles toward your destination. I recognize there are some C++ wrapper API's that do more or less exactly that, which is why I said: you might as well learn both of them so you do not have to depend on wasting resources to work around your weaknesses.
Originally Posted by
kmdv
p = "Jennifer";
Could somebody explain it to me?
Since "a" is not const and it is a union there is no point in "p" being const.