Update:
My first thought was that, compiler might be generating its own default Derived::operator =. That's wrong because it uses Base::operator =
. Same holds true for other operators as well.
If I use private inheritance, then Base::foo()
is automatically hidden (even without using). But no effect on Base::operator =
, it still works.
Your first though was correct. You didn't declare a copy assignment operator, so one was implicitly declared for you. You then odr-used that implicitly-declared copy assignment operator, so the compiler provided the implicitly-defined copy assignment operator. The implicitly-defined copy assignment operator of a struct or class performs a memberwise copy assignment of the class's base classes and then it's non-static data members.
That implicitly-defined copy assignment operator is a class member. It doesn't matter one bit that you have hidden the base class copy constructor to the outside world via using
or via private inheritance because that base class assignment operator is visible to this implicitly-defined copy assignment operator.