The problem is that using-declarations is not considered a user-declared assignment operator [namespace.udecl] :
4 - [...] If the assignment operator obtained from the base class to the scope of the derived class has a copy / move signature for the derived class (12.8), the use-declaration does not in itself suppress the implicit declaration of the assignment operator of the derived class [. ..]
(In any case, using Base::operator= provides you with an assignment operator with the parameter type Base const& , which is not one of the parameter types that qualifies as a copy assignment operator [class.copy] / 17 - T , T& , T const& , etc. d.)
Since Derived does not have a user-defined copy destination operator, it is generated automatically, which ends with a call to IDerived::operator= , which calls IBase::operator= . Note that automatically generated copy assignment operators invoke subobject assignment operations, ignoring virtual overrides:
Each subobject is assigned in a way corresponding to its type:
- if the subobject is of class type, as if calling
operator= with the subobject as an expression of the object and the corresponding subobject x as one argument of the function (as if by explicit qualification, is ignoring any possible virtual override functions in more derived classes); [...]
It would be correct to write:
Base& operator=(Derived const& other) { return Base::operator=(other); }
Please note that MSVC 2015 rejects your code, but works with the above fix:
main.cpp(36): warning C4250: 'Derived': inherits 'Base::Base::operator =' via dominance main.cpp(14): note: see declaration of 'Base::operator =' main.obj : error LNK2019: unresolved external symbol "public: virtual class IBase & __thiscall IBase::operator=(class IBase const &)" ( ??4IBase@ @ UAEAAV0@ABV0 @@Z) referenced in function "public: class IDerived & __thiscall IDerived::operator=(class IDerived const &)" ( ??4IDerived@ @ QAEAAV0@ABV0 @@Z) main.exe : fatal error LNK1120: 1 unresolved externals
source share