It works, no crashes. Is it OK?
edit: the reason I ask is that std::string s = "a" + "b" + "c"; produces a compiler error, and (std::string)"a" just tells the compiler, “Just presume what “a” is pointing at is an std::string”. And I didn’t actually know how std::string is implemented.
Thanks for the feedback from everyone.
Yes.
+is left-associative, so it’s equivalent to((std::string)"a" + "b") + "c".std::string::operator+is overloaded to take aconst char *as the argument.