How to implement homonym override, function rewriting and Polymorphism in C++
This article is about how C++ implements homonym overrides, function rewriting and polymorphism. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Override # includeusing namespace std;class Base {public: int masked data; Base (): m_data (1) / / parent class initialized to 1 {}}; class Derived: public Base {public: int masked data; Derived (): m_data (2) / / subclass initialized to 2 {}}; int main () {Derived d / / the m_data of the parent class is hidden, but it still exists. You can access cout through the:: character