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 form t x = { }; equivalent t 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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -