cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/06/09:50:27

From: makulik AT tf16 DOT mch DOT sni DOT de (Makulik.Guenther T 27528 R 91-811 WS tx24 )
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Overloading the << operator.
Date: 6 Aug 1997 10:16:12 GMT
Organization: Siemens Nixdorf Inc.
Lines: 22
Message-ID: <5s9itc$1nv$1@horus.mch.sni.de>
References: <33e40528 DOT 21082895 AT news DOT bright DOT net> <Pine DOT SUN DOT 3 DOT 93 DOT 970803122401 DOT 8956A-100000 AT degobah> <33E4D275 DOT 772779FD AT alcyone DOT com>
NNTP-Posting-Host: tmntn.mch.sni.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Erik Max Francis (max AT alcyone DOT com) wrote:
: 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.
That's not the problem for sure! It is allowed to declare the parameter as non-const.

It would be helpful to have a look at a larger piece of code, because the piece you
posted looks right. I used overloading of the ostream operator<< with DJGPP and it
worked fine.

cu
guenther

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019