home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Problem with C++ V3.0.1 on Sun3
- Message-ID: <1992Jul31.163725.9936@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Jul30.002138.28759@trl.oz.au>
- Date: Fri, 31 Jul 1992 16:37:25 GMT
- Lines: 32
-
- root@trl.oz.au (System PRIVILEGED Account) writes:
-
- [ code simplified ]
-
- | class A {
- | public:
- | operator int();
- | friend ostream& operator<<(ostream&, const A&);
- | };
-
- | main()
- | {
- | A a;
- | cout << a << endl;
- | }
-
- | My problem is that the compiler complains about an ambiguous operator
- | << defined for
- | (ostream &, const A&) in the above source
- | clashing with << defined for
- | (ostaream &, int) defined in iostream.h.
-
- | The problem is obviously caused by the int() operator in class A,
- | and indeed removing this operator causes the problem to go away.
-
- This is a compiler bug. There is an exact match for the friend
- function, and a user conversion for the iostream.h function. hte
- friend function should be preferred.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-