OOPS Tutorials:Inheritance

 What is inheritance?
           Inheritance is again a very important feature of the object-oriented programming. It is the second feature of the OOPS concept.The concept of inheritance is derived from the fact that the children inherit many attributes from their parents. In addition to these characters, they also have their own characteristics.                
             Inheritance is the process by which objects of one class acquire objects of another class. The class from which new class is derived is known as "Base class". And the class which is inherited from the base class is known as "Derived class".  In the object-oriented programming , a base class is analogous to a parent and a derived class is analogous to the children.The concept of inheritance provides the way for code reusability. We can implement the super class which is called as abstract class using the inheritance concept.

Syntax:

class CParent
{
}

class CChild:CParent
{
}

In the above syntax it can be said that the child is going to inherit all the features of the parent which is the base class and also has some extra features.

Examples for inheritance:
Inheritance depends upon " is a" relationship
1. Car is a Vehicle.(Here car is inherited from the vehicle)
2. Mango is a fruit.
3. Chair is a furniture.

Notes:
1. When an object of child class is created all the data members of the parent class and the child class are allocated memory irrespective of their access specifier i.e public or private.

2. Always the parent constructor is executed first.

3. Every child class constructor by default calls default constructor of parent class.
          To know more about constructors visit OOPS tutorial for the video sessions.
Learn more about inheritance and also about abstract classes with video sessions . Also get the best training of Dot Net at DeccanSoft




Comments