Mail Archives: djgpp/1997/08/06/15:21:01
Insomnia wrote:
> > Is there any way to overload the << operator as a friend function in a
> > class in djgpp? I tried the following:
> >
> > friend ostream &operator<<(ostream &, MyClass &);
> >
> > Unfortunately, djgpp didn't like this. Anyone have any ideas?
> >
> Try:
> friend ostream &operator << (ostream &, const MyClass &);
> ^^^^^
> This works fine for me.
Overloaded operators, friend functions or member functions, certainly can
take non-const references to objects as arguments.
His problem is more fundamental than this. I suspect he's doing something
like including the friend keyword when defining the friend function,
rather than when declaring it.
He'll have to post a short snippet of the example code, including the
error and which line it's on, to get more help.
--
Erik Max Francis, &tSftDotIotE / email / mailto:max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"Love is not love which alters / when it alteration finds."
/ William Shakespeare, _Sonnets_, 116
- Raw text -