I can't realize how could it be possible to print a string this way without any complaint by the compiler:
std::cout << "Hello " "World!";
In fact, the above line works exactly like:
std::cout << "Hello " << "World!";
Is there an explanation for this behaviour?
Adjacent literal tokens are concatenated automatically, it's part of the standard.
6) Adjacent
ordinary stringliteral tokens are concatenated.Adjacent wide string literal tokens are concatenated.
(C++03)
In C++, literals tokens can be concatenated thusly:
const char* thingy = "Hello" "World";
"Hello"
and "World
" are each a literal token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With