Home >>C++ Tutorial >C++ method Overriding
Function overriding in C++ is defined as the function that is defined by the derived class has also been defined by the base class. This function overriding in C++ is mainly used to achieve the runtime polymorphism. This overriding of the functions enables the programmer to deliver implementation the function that is specific and has been already been delivered by its base class.
C++ Function Overriding Example
Here is a simple example of the function overriding in the C++ language that will deliver you an understanding about the process that is being followed to override a function:
#include <iostream> using namespace std; class base // Here we declared parent/Base Class. { int x; public: void show() { cout<< "THis is Base Class "; } }; class child : public base // Here we declared child class. { int y; public: void show() { cout<<"THis is child Class"; } }; int main(void) { child obj; obj.show(); return 0; }