mardi 2 février 2016

Appending characters to a string, what is the difference?

auto str = std::string();

auto a = 'a';
auto b = 'b';

//this gives the desired output
str = str + a + b;

//this gives some garbage value
str += a + b;

What is the difference between these two expressions semantically?

Isn't the second one evaluated also as: str = str + a + b; ?

Aucun commentaire:

Enregistrer un commentaire