Hi,
I am trying to return a variable in a string, like this:
I didn't think this would work, and it didn't, so how can i do this? I don't want to do it with cout instead of return.Code:void toString()
{
return "The variable is" +variable1;
}
Printable View
Hi,
I am trying to return a variable in a string, like this:
I didn't think this would work, and it didn't, so how can i do this? I don't want to do it with cout instead of return.Code:void toString()
{
return "The variable is" +variable1;
}
Use the string class:
Code:#include <string>
using namespace std;
string toString() {
return "The variable is: " + sVar;
}
K, thanks, and i just realized i put this in chit chat, not C++, sorry everyone.