Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ulysses!hector!jss From: jss@hector.UUCP (Jerry Schwarz) Newsgroups: comp.lang.c++ Subject: Re: "Inheritance" of operator=() Keywords: user error or cfront error? Message-ID: <11543@ulysses.homer.nj.att.com> Date: 18 May 89 17:28:27 GMT References: <863@ethz.UUCP> <11519@ulysses.homer.nj.att.com> <933@ethz.UUCP> Sender: netnews@ulysses.homer.nj.att.com Reply-To: jss@hector.UUCP (Jerry Schwarz) Organization: AT&T Bell Laboratories Lines: 51 In article <933@ethz.UUCP> marti@ethz.UUCP (Robert Marti) writes: >In article <11519@ulysses.homer.nj.att.com>, jss@hector.UUCP (Jerry Schwarz) >writes: > >I am glad to hear that the semantics of (user-defined) assignment has >changed in 2.0, although I am not quite sure what you mean when you say >that it is defined to be "recursive". Could you elaborate on that? > The semantics of user-defined assignment has not changed. It remains that you call the user-defined function. Its the semantics of builtin assignment on classes that has changed. Assignment for a class K means to assign each "part" of K according (recursively) to the appropriate definition of assignment for that part. A part is either a member declared as a member of K or the parts of K that result from inheritance. For example. class K { public: K& operator=(const K&) ; } ; class B { private: int b ; protected: virtual void f() ; B& operator=(const B&) ; } ; class D : public B { K k ; int x ; } D d1, d2 ; // The "parts" of d1 are d1.k, d1.x (B&)d1 d1 = d2 ; // copy d2.x to d1.x call K::operator= to "assign" // d2.k to d1.k. And call B::operator= to "assign" // the base part of d2 to the base part of d1. // The vtable pointer is not copied. Jerry Schwarz AT&T Bell Labs, Murray Hill