🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2047

operator(s) << are member functions. Why?

#2047
From: Martin Prange
Date: Tue, 26 Sep 1995 15:13
21 lines
1519 bytes

To make the operator(s) << (from iostream.h) usable by other classes,
they must be derived by the appropriate iostream-class.

As non-member functions they could be used by any class, 
that could be casted to (ostream&) by means of e.g. operator ostream&.
( Which is, what I actually wanted to. )

So, the question is:
Why are these operators declared (and implemented , of course), as members ?
Are there design issues I`ve been missing so far?

--
 Martin Prange / Member of ALMAP Team / ALCATEL +49 030 3120 
 just alcanet: prange@sel.bln.alcatel.de else @cs.tu-berlin.de
 If you believe, the opinions expressed here are mine - you got it

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <PRANGE.95Sep26142017@slbwa7.bln.sel.alcatel.de>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: prange@slbwa7.bln.sel.alcatel.de (Martin Prange)
Newsgroups: comp.std.c++
Subject: operator(s) << are member functions. Why?
Date: 26 Sep 1995 15:13:41 GMT
Organization: SEL-Alcatel-Berlin
Sender: SNews@slbh01.bln.sel.alcatel.de (News Administrator) (News Administrator)
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <PRANGE.95Sep26142017@slbwa7.bln.sel.alcatel.de>
Reply-To: prange@bln.sel.alcatel.de
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
Apparently-To: comp-std-c++@uunet.uu.net
Content-Length: 644
X-Lines: 17
Originator: clamage@taumet