Hi all. I want to know how to return the value of a string...when I try to do that, it gives me an error about converting a char * to an int.
So, how do I return the value of a string?
I have tried:
Code:
return stringname;
return *stringname;
I have to go for awhile, so don't expect any immediate replies from me. Thanks in advance.
Edit:
To be more specific, I am returning the value of a string that the user typed in, for example:
Code:
class littleCrab {
public:
littleCrab::whatcolor() {
cout<<"What color is your crab?"<<endl;
cin>>color;
return *color;
//^^^^^^^^^^^^^^^
}
littleCrab::howmanyeyes() {
cout<<"How many eyes does your crab have?"<<endl;
cin>>eyes;
cout<<"Your crab has "<<eyes<<endl;
return eyes;
}
private:
char *color;
int eyes;
int legs;
};
Awe, come'on! Someone must know!