Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!milano!cadillac!puma!vaughan From: vaughan@puma.cad.mcc.com (Paul Vaughan) Newsgroups: comp.lang.c++ Subject: conversions Message-ID: <7633@cadillac.CAD.MCC.COM> Date: 11 Apr 90 20:50:25 GMT Sender: news@cadillac.CAD.MCC.COM Lines: 34 The following program compiles cleanly under g++-1.37.1, but gets three errors under cfront (Sun CC, actually). --------------------------- class Int { int i; public: Int(int j) : i(j) {} Int(Int& I) { i = I.i; } operator int() { return i; } operator int&() { return i; } }; main() { Int i = 4; i += i; // line 29 } ------------------------ CC -c convert.cc CC convert.cc: "convert.cc", line 30: error: ambiguous conversion of Int "convert.cc", line 30: error: ambiguous conversion of Int "convert.cc", line 30: error: bad operand types Int Int for += 3 errors Any comments on why CC generates these errors, and whether or not this is the right thing to do? I realize that a class that works Exactly like an int for both reading and assignment probably isn't very useful, but should I be able to do it this way? Paul Vaughan, MCC CAD Program | ARPA: vaughan@mcc.com | Phone: [512] 338-3639 Box 200195, Austin, TX 78720 | UUCP: ...!cs.utexas.edu!milano!cadillac!vaughan