home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!pipex!warwick!bham!bhamvx!mccauleyba
- From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
- Subject: Re: Just what is so great about streams?
- Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
- Message-ID: <1992Nov18.182420.1@vax1.bham.ac.uk>
- Date: Wed, 18 Nov 1992 18:24:20 GMT
- Lines: 40
- References: <1992Nov12.061942.16473@nuscc.nus.sg> <TMB.92Nov13102951@arolla.idiap.ch> <6994@taurus.cs.nps.navy.mil> <1992Nov18.134551.5782@bcrka451.bnr.ca>
- Organization: University of Birmingham
-
- In article <1992Nov18.134551.5782@bcrka451.bnr.ca>, sjm@bcrki65.bnr.ca (Stuart MacMartin) writes:
- > In article <6994@taurus.cs.nps.navy.mil> skip@taygeta.oc.nps.navy.mil (Skip Carter) writes:
- >> Now the TimeStamp class can write a comment WITH NO CHANGES MADE TO
- >> THE TIMESTAMP CLASS.
- ...
- >> In fact, TimeStamp can properly write to any class that is ultimately
- >> derived from ostream.
- >>
- >
- > What about fout << t << t << endl;
- > The wrong operator<<() will be called for the second output unless you provide
- > the appropriate friend function for TimeStamp, no?
- No.
-
- What wrong operator<<()? There only is one that can possibly be called:
- ostream& operator<< (ostream&,const TimeStamp&)
-
- Are you thinking that << associates right?
-
- fout << t << t << endl;
- is not...
- operator<<(fout,operator<<(t,operator<<(t,endl)))
-
- it is..
- operator<<(operator<<(operator<<(fout,t),t),endl)
- \-----v---------/
- Returns a ref to `fout'
- \---------------v--------------/
- Returns a ref to `fout'
-
- the inner to calls to operator<< call the same operator.
- OK so an ostream& is used to refer to `fout' but when we get down to
- the nitty-gritty of stream io everything is virtual so this doesn't matter.
- --
- \\ ( ) No Bullshit! | Email: B.A.McCauley@bham.ac.uk
- . _\\__[oo from | Voice: +44 21 471 3789 (home)
- .__/ \\ /\@ /~) /~[ /\/[ | Fax: +44 21 625 2175 (work)
- . l___\\ /~~) /~~[ / [ | Snail: 197 Harborne Lane,
- # ll l\\ ~~~~ ~ ~ ~ ~ | Birmingham, B29 6SS, UK
- ###LL LL\\ (Brian McCauley) | ICBM: 52.5N 1.9W
-