c++initialization

String initialization without assignment and braces?


I have a question about following code segment which presents in "A Tour of C++, Third Edition, pg:111"

string s "Hello ";

Is this a typo or is there an initialization syntax like this?


Solution

  • I cannot see that this could be anything else than a typo (on godbolt).

    I'm guessing he means (for instance):

        std::string s{"Hello"};