Is following pattern ok/safe ? Or are there any shortcomings ? (I also use it for equality operators)
Derived& operator=(const Derived& rhs)
{
st
That's better to use
Base::operator=(rhs);
because if your base class have a pure virtual method the static_cast is not allowed.
class Base {
// Attribute
public:
virtual void f() = 0;
protected:
Base& operator(const Base&);
}
class Derived {
public:
virtual void f() {};
Derived& operator=(const Derived& src) {
Base::operator=(src); // work
static_cast (*this) = src; // didn't work
}
}