lundi 4 novembre 2019

C++ Adding to a string (Output)

Below is a cout of a c++ statement:

cout << "TESTING" + 2 << endl;

I understand why this statement will print out sting. But the question I have is if I do the code below it will cause an error. I don't understand why as this is the same thing. Sorry for a basic question I am new to c++.

 string t = "TESTING";
 cout << t + 2 << endl;

Thanks in advance for any help. :)

Aucun commentaire:

Enregistrer un commentaire