Last modified on April 3rd, 2020
What is member functions overriding?
Function overriding means to have the two or more functions with same name and with same signatures. Same signature means that to have the same name, same number of parameters and same data types.
A deriver (child) class inherits the data members and member functions of base (parent) class. Function overriding is just like creating a new version of an old function, in the child class.
Give example of member functions overriding?
Suppose Class A and class B have two functions with same name and same parameters . Then we can say that the function in class B overrides the function in class A.
using namespace std;
cout<<“print function for class A”<<endl;
class B : public A
cout<<“print function for class B”<<endl;
object.A :: print();
Here we have two functions of print() with same name and with same parameters…This is actually the function overriding.