Re: Overloading operator << and >> in C++

Kirk Nesbitt (knesbitt@nospam.opennet.net.au)
Sun, 5 Nov 1995 15:27:06 +1000

Ive got a problem and i need help

I have overloaded both operator << and >> so that they will work if an
object is defined and used like below.

object me;

cout << me;

but i cant seem to get them to work when i do this..

object* me
ifstream infile("INFILE")

new me;
infile >> me;
cout << me;
delete me;

i did try the below but it wont work, the compiler says it is an illegal
structure operation. in the class where an actual object is declared.

(istream& i, object* p)
{ return i >> p->SomeField >> p->AnotherField; }

Help!

Kirk A. Nesbitt