🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2150
From: Martin Prange
Date: Mon, 09 Oct 1995 15:46
20 lines
1462 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.95Oct9113821@slbh08.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@slbh08.bln.sel.alcatel.de (Martin Prange)
Newsgroups: comp.std.c++
Subject: operator(s) << are member functions. Why?
Date: 9 Oct 1995 15:46:35 GMT
Organization: SEL-Alcatel-Berlin
Approved: clamage@eng.sun.com (comp.std.c++)
Distribution: world
Message-ID: <PRANGE.95Oct9113821@slbh08.bln.sel.alcatel.de>
Reply-To: prange@bln.sel.alcatel.de
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: slbemu.bln.sel.alcatel.de
Content-Length: 646
X-Lines: 16
Originator: clamage@taumet