Inheritance allows software developers to derive a new class from the existing class. The derived class inherits features of the base class (existing class).
Suppose, both base class and derived class have a member function with same name and arguments (number and type of arguments).
If you create an object of the derived class and call the member function which exists in both classes (base and derived), the member function of the derived class is invoked and the function of the base class is ignored.
This feature in C++ is known as function overriding.
To access the overridden function of the base class from the derived class, scope resolution operator :: is used. For example,
If you want to access
getData() function of the base class, you can use the following statement in the derived class.