C++/string str = "hello " "world" "!"
Expert: Zlatko - 12/1/2010
QuestionHello,
As you can see on the Subject, do you know why we can use double quote to concatenate the stirngs?
Regards,
lzzzz
AnswerHello lzzzz. I hope I spelled your name right!
The concatenation is a language feature handled by the compiler. It is not done while the program is running. As long as you have only quoted string constants, the compiler will connect them into one long string. This is useful for breaking up large strings across many lines to make your program neater.
You could have
string str = "hello"
"world"
"!"
But you cannot have
string str1 = "hello"
string str2 = str1 "world";
I hope that helps you out.
Best regards
Zlatko