|
-
Apr 28th, 2001, 01:51 PM
#1
Thread Starter
Fanatic Member
Question about returning variables and text
Hi,
I am trying to return a variable in a string, like this:
Code:
void toString()
{
return "The variable is" +variable1;
}
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.
Alcohol & calculus don't mix.
Never drink & derive.
-
Apr 28th, 2001, 02:18 PM
#2
Monday Morning Lunatic
Use the string class:
Code:
#include <string>
using namespace std;
string toString() {
return "The variable is: " + sVar;
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 28th, 2001, 02:21 PM
#3
Thread Starter
Fanatic Member
K, thanks, and i just realized i put this in chit chat, not C++, sorry everyone.
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|