Until a test I\'ve just made, I believed that only Constructors were not inherited in C++. But apparently, the assignment operator=
is not too...
The assignment operator is technically inherited; however, it is always hidden by an explicitly or implicitly defined assignment operator for the derived class (see comments below).
(13.5.3 Assignment) An assignment operator shall be implemented by a non-static member function with exactly one parameter. Because a copy assignment operator
operator=
is implicitly declared for a a class if not declared by the user, a base class assignment operator is always hidden by the copy assignment operator of the derived class.
You can implement a dummy assignment operator which simply forwards the call to the base class operator=
, like this:
// Derived class
template class Derived : public Base
{
public:
template::value>::type>
inline Derived& operator=(const T0& rhs)
{
return Base::operator=(rhs);
}
};