c++ - Extra curly braces while initializing a string -
according question what string array[] = ""; mean , why work? want ask difference between s1 , s2 in code below:
int main() { const char* s1 = { "hello" }; // strange work followed const char* s2 = "hello"; // ordinary case return 0; }
why curly braces permitted? reference c++ standard useful.
in c++98 (and c++03) pretty simple; in clause 8.5:
14 - if
t
scalar type, declaration of formt x = { };
equivalentt x = a;
in c++11 covered list-initialization (8.5.4p3):
[...] if initializer list has single element of type e , either t not reference type or referenced type reference-related e, object or reference initialized element [...]
i think same question initializing scalars braces.
Comments
Post a Comment