I was faced with this question for a C++ exam and as much as I think I know the answer, the question confused me enough that I rather have a "Second opinion" per say... haha.
a) The literal
"Hello, World!"is a C-Style string. What is its type?b) Given that the type of C-style string and the type
std::stringare different, how is it possible that the linestd::string hello("Hello,World!");compiles without errors/warnings (assuming the<string>header has been included)?
From my understanding the C-Style string is of type (a) array of chars while std::string is of type string... and (b) the reason it compiles is that in C++ the whole casting to chars and all that is done "under the hood" by the type string rather than "in the code".
Am I correct?
Thanks!