An inherited nonvirtual function shall not be redefined in a derived class.
Prevent an object from exhibiting “two-faced” behavior.
Vulnerability and risk
Nonvirtual functions are statically bound. In essence, a nonvirtual function will hide its corresponding base class version. Hence a single derived class object may behave either as a base class object or as a derived class object depending on the way in which it was accessed—either through a base class pointer/reference or a derived class pointer/reference.
Mitigation and prevention
To avoid this duality in behavior, nonvirtual functions should never be redefined.
class Derived : public Base
Base* base_ptr = &derived; // Points to derived
Derived* derived_ptr = &derived; // Points to derived
base_ptr->mf(); // Calls Base::mf() *** Different behavior for same object!!
derived_ptr->mf(); // Calls Derived::mf()