C
Charles
I am learning from the Accelerated C++ book. The following example
doesn't work and I don't know why:
#include <iostream>
#include <string>
int main () {
const std::string exclam = "!";
const std::string message = "Hello" + ", world" + exclam;
return 0;
}
But if I invert strings, it works:
#include <iostream>
#include <string>
int main () {
const std::string exclam = "!";
const std::string message = ", world" + exclam + "Hello";
return 0;
}
Unfortunately there's no explanation why. Could you tell me please?
Thanks.
doesn't work and I don't know why:
#include <iostream>
#include <string>
int main () {
const std::string exclam = "!";
const std::string message = "Hello" + ", world" + exclam;
return 0;
}
But if I invert strings, it works:
#include <iostream>
#include <string>
int main () {
const std::string exclam = "!";
const std::string message = ", world" + exclam + "Hello";
return 0;
}
Unfortunately there's no explanation why. Could you tell me please?
Thanks.