How do you append an int to a string in C++?
I suggest you look closely at the above post to tackle your problem.
In C or C++, concatenation is done best using string streams. But to specifically answer your question:
This C++ Code Shows No Output:
int x = 10;
cout<<"Hello C++ " + x ; //uses "+" as you are trying to concatenate an "int" to some output to the stream
But This One which Shows An Output:
int x = 10;
cout<<"Hello C++ "; //output directly to stream
cout<<x<<endl; //same here, no concatenation
What's the problem then, are they exactly the same ?
The problem is with "+" concatenation to the stream and NO, they aren't the same! :)