Please see this code fragment:
class Base {
public:
const Base& foo (const int&);
const Base& operator=(const int&);
};
class Derived : public Base {};
void fn() {
Derived c;
c.foo(3); // compiles fine (as expected)
c = 3; // error: no match for ‘operator=’
}
The question is why is operator=
not inherited from Base
to Derived
just like foo()
is?
Is there something in the standard that makes operator=
special with respect to inheritance?
Thanks