C++ Overriding


Function overriding is the main concept in C++ language.


Function Overriding

Function overriding achieved by the same function and the same parameter in base class as well as in derived class. Function overriding used only in different classes.

Syntax:

class A {  
	public:  
		void show(){
         //body of the function. 
        }    
};
class B {  
	public:  
		void show(){
         //body of the function. 
        }    
}; 
C++ function overloading

Example:

#include <iostream>    
using namespace std;  

class A // base class
{  
	public:  
        void show(){
        	cout << "Base class Function" << endl; 
        }
};  
class B: public A
{  
    public:  
        void show(){
        	cout << "Derived class Function" << endl; 
        }
};       
int main() {  
   B b;
   b.show();
   return 0;
}



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.