# Problem with sub class call

## Recommended Posts

toogreat4u    127
I have a problem that I can not figure out. I am not sure how to explain this but basically I have a class that has a private member as another class that is already defined and works properly. I want to use ins >> text.value where value is the type of the previously defined class. The previously defined class function that I am trying to use is this:
istream& operator >>(istream& ins, StringVar& the_string)
{
ins >> the_string.value;
return ins;
}

The text class has this call:
istream& operator >>(istream& ins, Text& the_text)
{
ins >> the_text.value;
return ins;
}

However when I compile I get an error message that says: error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'StringVar *' (or there is no acceptable conversion) I am wondering how to correctly use these class calls. In StringVar class value is char* and in Text class value is StringVar*. Thanks for any help.

##### Share on other sites
sheep19    494
It would help if you showed us your classes.

##### Share on other sites
Ftn    462
The operator you're trying to call takes reference to StringVar as parameter. Text::value is StringVar* (pointer). Just as the error describes, you have to dereference the pointer:

istream& operator >>(istream& ins, Text& the_text)
{
assert(the_text.value);
ins >> *the_text.value;
return ins;
}