home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!doc.ic.ac.uk!mrccrc!warwick!bham!bhamvx!mccauleyba
- From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
- Subject: Re: Compiler Bug (AT&T 2.1) ?
- Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
- Message-ID: <1992Nov17.212613.1@vax1.bham.ac.uk>
- Date: Tue, 17 Nov 1992 21:26:13 GMT
- Lines: 29
- References: <1992Nov17.181306.8081@lut.ac.uk>
- Organization: University of Birmingham
-
- In article <1992Nov17.181306.8081@lut.ac.uk>, J.March@lut.ac.uk writes:
- > Consider:
- > class Elt { public: Elt(int*); };
- > class List { public: List(const Elt&); };
- > void main() { List L(new int(1)); }
- ^?^
- [example cut down to relevant bits ]
- >
- > Shouldn't this fail because the declaration of L doesn't match any of
- > the constructors for class List?
- No, the complier is allowed to insert up to one user-supplied type
- conversion for each parameter in any parameter matching situation
- (except templates).
-
- Since the type conversion constructor (aka one parameter constructor)
- Elt::Elt(int*) has been declared the complier can compile main() as:
-
- main() { List L(Elt(new int(1))); }
-
- This is now an exact match.
-
- A tempoary Elt is created to satisfy the need for a reference to an Elt.
- --
- \\ ( ) 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
-