home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!mips!mips!munnari.oz.au!trlluna!titan!root
- From: root@trl.oz.au (System PRIVILEGED Account)
- Subject: Problem with C++ V3.0.1 on Sun3
- Message-ID: <1992Jul30.002138.28759@trl.oz.au>
- Organization: Telecom Research Labs, Melbourne, Australia
- Date: Thu, 30 Jul 1992 00:21:38 GMT
- Lines: 50
-
- I have been trying to make C++ V3.0.1 on a sun 3. In fact the make
- has been successful (sort of). After installation I have tried to
- compile the following program
-
- #include <iostream.h>
-
- class A {
- public:
- int a;
- operator int() const {return a;}
- friend ostream& operator<<(ostream& o, const A&) {
- return o;
- }
- };
-
- 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.
-
- However:
- 1. I want to be able to do the above and believe taht I should be able
- to.
-
- 2. The doco seems to indicate that what I have done is legal.
-
- 3. The same sources compiled on a Sun 4 allow the above code to compile
- without hitch.
-
- 4. (if relevent) It worked under CC V2.1.
-
- Does anyone know offhand what I have done wrong?
- I would be very grateful for any leads.
-
- Thanx ...mcf
-
- Michael Flower
- Artificial Intelligence Systems Email: m.flower@trl.oz.au
- Telecom Research Laboratories Voice: +61 3 541 6179
- Melbourne, AUSTRALIA Fax: +61 3 543 8863
-