C++ Function Overriding1 min read

Function overriding allows us to define a function at a derived class that is already present in a base class. And that base is said to be overridden. Both derived and base class has the member function with the same name, same return type, and same arguments list.

And the decision made to call the required function is done at the run time. Hence, it is used to achieve the Runtime polymorphism.

Let us understand through an example of function overriding using C++. It involves inheritance in a program given below.

Example of Function Overriding in C++

Output:


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More