I am a novice in C++ and i am referring Accelerated C++. While trying one of its exercise questions which says:
Are the following definitions valid? Why or why not?
const std::string exclam = "!";
const std::string message = "Hello" + ", world" + exclam;
When i tried & executed the program i am getting an error as:
invalid operands of types to binary operator +.
But the following code works perfectly fine:
const std::string hello = "Hello";
const std::string message = hello + ", world" + "!";
I am not clear with its execution! why this concatenation in the first case not working?
Thanks!I am using DEV C++.