Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!kth!draken!tut!tukki!sakkinen From: sakkinen@tukki.jyu.fi (Markku Sakkinen) Newsgroups: comp.lang.c++ Subject: Re: Arguments to Overloaded Operators Keywords: overloading Message-ID: <884@tukki.jyu.fi> Date: 13 Jun 89 09:05:22 GMT References: <11032@orstcs.CS.ORST.EDU> <1100@cadillac.CAD.MCC.COM> <238@pink.ACA.MCC.COM> <868@tukki.jyu.fi> <244@pink.ACA.MCC.COM> <5023@wiley.UUCP> Reply-To: markku@jytko.jyu.fi (Markku Sakkinen) SAKKINEN@FINJYU.bitnet (alternative) Organization: University of Jyvaskyla, Finland Lines: 42 In article <5023@wiley.UUCP> simpson@poseidon.UUCP (Scott Simpson) writes: -In article <244@pink.ACA.MCC.COM> rfg@pink.aca.mcc.com.UUCP (Ron Guilmette) writes: ->In article <868@tukki.jyu.fi> markku@jytko.jyu.fi (Markku Sakkinen) SAKKINEN@FINJYU.bitnet (alternative) writes: ->>In article <238@pink.ACA.MCC.COM> rfg@pink.aca.mcc.com.UUCP (Ron Guilmette) writes: ->>One example of these ->>is the widening of char values to int in many contexts: it even prevents us ->>from declaring an overloaded function pair corresponding to the _argument_ ->>types char and int. -> ->Who sez? I believe this is legal now. - -Indeed it is. See section 8.4.1, page 236 in Stroustrup. There are -a few lines like - - istream& operator>>(char&); - istream& operator>>(short&); - istream& operator>>(int&); - Scott Simpson - TRW Space and Defense Sector - oberon!trwarcadia!simpson (UUCP) - trwarcadia!simpson@usc.edu (Internet) This just came here when I had posted my previous (long) article. The trick is that this example has _reference_ arguments, which are almost the same as pointers. A pointer to char is definitely distinct from a pointer to int; this is clearly necessary for pointer arithmetic. If you look at subsection 8.2.1 (page 227) of Stroustrup, you can see (among others) the output operator and function ostream& operator<<(int) { ... } ostream& put(char&); Guess why there isn't ostream& operator<<(char); instead of the put function! Markku Sakkinen Department of Computer Science University of Jyvaskyla (a's with umlauts) Seminaarinkatu 15 SF-40100 Jyvaskyla (umlauts again) Finland