Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!texsun!pitstop!sundc!seismo!uunet!mcvax!cernvax!ethz!marti From: marti@ethz.UUCP (Robert Marti) Newsgroups: comp.lang.c++ Subject: "Inheritance" of operator=() Keywords: user error or cfront error? Message-ID: <863@ethz.UUCP> Date: 10 May 89 12:13:57 GMT Organization: ETH Zuerich Lines: 54 Disclaimer: I am fairly new at trying out some things in C++, so don't flame me if I overlooked something obvious. The following code gives an error on the line indicated with <<<<< when compiled on a Sun-3/50, SunOS 4.0.1, with cfront 1.2.1. ===== struct ObjDescr { void* val; int ref_count; }; class Object { protected: ObjDescr* obj; public: Object(); Object(Object& another); void operator=(Object& another); virtual ~Object(); virtual int operator==(Object& another); }; class IntObj : public Object { public: IntObj(); IntObj(int i); int operator==(Object& another); operator Object(); }; // definitions of Object:: and IntObj:: member functions ... main() { IntObj o; IntObj o1 = 1; IntObj o2 = 2; o = o1; // <<<<< error: assignment not defined for class IntObj o.operator=(o2); } ===== Why is this? The "bible" somewhere states that x operator@ y is equivalent (among other things) to x.operator@(y), so I feel that cfront should figure out in both cases that I want the "inherited" member function Object::operator= for the IntObj o ... -- Robert Marti Phone: +41 1 256 52 36 Institut fur Informationssysteme ETH-Zentrum CSNET/ARPA: marti%inf.ethz.ch@relay.cs.net CH-8092 Zurich, Switzerland UUCP: ...uunet!mcvax!ethz!marti