Out of curiosity, I\'m wondering what the real underlying type of a C++ string literal is.
Depending on what I observe, I get different results.
A typeid tes
The type of a string literal is indeed const char[SIZE]
where SIZE
is the length of the string plus the null terminating character.
The fact that you're sometimes seeing const char*
is because of the usual array-to-pointer decay.
But I don't see how it could be
const char *
as the following line is accepted by VS12:char* s = "Hello";
This was correct behaviour in C++03 (as an exception to the usual const-correctness rules) but it has been deprecated since. A C++11 compliant compiler should not accept that code.