If base class and derived class have member function with same name and arguments. If we create an object of derived class so it access the member of own class. If base class and derived class have member functions with same name and arguments. If you create an object of derived class and write code to access that member function then, the member function in derived class is only invoked, i.e., the member function of derived class overrides the member function of base class. This feature in C++ programming is known as function overriding.
e.g: Program for function overiding#include<conio.h> #include<iostream.h> class Base1{ public: void show(){ cout<<"\nThis is Base 1 class"; } }; class Base2{ public: void show(){ cout<<"\nThis is Base 2 class"; } }; void main(){ clrscr(); Base2 b; b.show(); getch(); }O/P
This is Base 2 class