Overriding
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
// Overriding is the re definition of a function name with same signatue
class BaseClass
{
public :
void display()
{
cout<< "display function within base class" << endl;
}
};
class ChildClass:public BaseClass
{
public :
void display() // display function within base class is overridden here
{
cout<< "display function within child class" << endl;
}
};
int main()
{
cout<< "Example of overriding" << endl;
ChildClass ch;
ch.display();
return 0;
}
Output:
Example of overriding
display function within child class