Override Keyword in C++ programming

C++Server Side ProgrammingProgramming

In this tutorial, we will be discussing a program to understand override keyword in C++.

Override keyword is used to override the function in a base class and define a separate function with the same signature in the child class.


 Live Demo

#include <iostream>
using namespace std;
class Base {
   //function to be override
   virtual void func() {
      cout << "I am in base" << endl;
class derived : public Base {
   void func(int a) {
      cout << "I am in derived class" << endl;
int main(){
   Base b;
   derived d;
   return 0;


I am in derived class
Updated on 14-Apr-2020 12:10:44