TITLE: Virtual operator = PROBLEM: skochhar@cvbnet.prime.com (Sandeep Kochhar) Any thoughts on the following? 1. Should operator= never be virtual, or are there circumstances in which it should be (if so, what are they?) ? I assume that since operator = usually has the form (for class Foo) of Foo& operator= (const Foo&) making it virtual means that a derived class, e.g., Bar, will have to define the above form, not it's own Bar& operator= (const Bar&) RESPONSE: rmartin@thor.Rational.COM (Bob Martin), 23 Sep 92 Check out the ARM. ( I don't have mine with me, so I can't give you a reference). It will tell you that operator= is not inherited. You can verify this by attempting to inherit an operator= some time. It definitely does not work. This might cause you to believe that declaring them to be virtual is meaningless, but this is not the case. If class A has: virtual A& operator=(const A&); and Class B derived from A has virtual A& operator=(const A&); Then the following code will invoke B's operator=: A a; B b; A &r = b; r=a; // virtually invokes B's operator= So, you would want to make operator= any time you thought you might be doing polymorphic assigment through a reference.... Note however that both assignment operators have to have the same signature. The utility of A& B::operator=(const A&) is unclear, and probably not significant. The important thing to remember is that B& B::operator=(const B&); Does not override, nor virtually substitute for A& A::operator=(const A&); So, usually, there is not much point in making operator= virtual.