C++-what-is-overriding.aspx

What is overriding?

- Defining a function in the derived class with the same name as in the parent class is called overriding.

- In C++, the base class member can be overridden by the derived class function with the same signature as the base class function.

- Method overriding is used to provide different implementations of a function so that a more specific behavior can be realized.

- In overriding, methods have the same signature as the parent class method.

- Overriding is done in a child class for a method that is written in the parent class.

- It changes the existing functionality of the method.

- It happens at runtime.

- To override a method, a new method is defined in the child class with exactly the same signature as the one in the parent class. Due to this the functionality of the parent class becomes inaccessible.

Example:
class shape
   {
      getShape()
   {
      //code
   }
}
class circle
{
   getShape()
   {
      //code
   }
}
class square
{
   getShape()
   {
      //code
   }
}
What is copy constructor? - C++
Copy constructor - A copy constructor is a special type of constructor that is used to create an object...
Define private, protected and public access control - C++
Define private, protected and public access control - Private is the default access specifier for every declared data item in a class.....
What is Turbo C++?
Turbo C++ - Turbo C++ provides an environment called IDE (Integrated Development...
Post your comment