|
-
May 17th, 2002, 07:29 AM
#1
overloading operator >>
I am having trouble overloading operator >>. I can overload operator << with no problem but the reverse is giving me difficulty - perhaps I am missing something.
Here's some sample code.
class c2
{
public:
short i;
double d;
.... other members - different from class c1
c2();
~c2();
}
class c1
{
int i;
double d
... // other members
public:
c1& operator<<(const c2& p) { return *this;} // this compiles
c2& operator>>(const c1& p) {..} // this won't compile
In operator << I want to populate a c1 object with members from c2.
In operator >> I want to populate a c2 object with members from c1.
Any ideas - please help. I can't find a good example in any texts.
Thanks.
JB
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
|