Path: utzoo!attcan!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: Copying objects Message-ID: <55612@microsoft.UUCP> Date: 3 Jul 90 17:15:57 GMT References: <18753@well.sf.ca.us> <4853@darkstar.ucsc.edu> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Distribution: comp Organization: Microsoft Corp., Redmond WA Lines: 41 In article <4853@darkstar.ucsc.edu> ericg@ucschu.ucsc.edu (Eric Goodman) writes: >A virtual overloaded operator= should work (I'm assuming that virtual >operators are legal); Virtual overloaded operators are legal -- except operators new and delete. This is all neatly summerized in a table on page 306 of ARM. Interestingly, operator= has the unique characteristic of being virtual but not inherited! Can someone explain what this is suppose to mean? -- When I try the example below on my local compilers, it appears that virtual B& B::operator=(const B&) *is* being inherited. ??? extern "C" { #include "stdio.h" } class B { public: virtual B& operator=(const B&); }; B& B::operator=(const B&) { static int i=0; printf("%lX B::op=\n", (long)&i); return *this; } class D : public B { public: int i; }; main() { B& b1 = *new B; B& b2 = *new B; D& d1 = *new D; D& d2 = *new D; b1 = b1; d1 = d2; b1 = d1; }