Advertisements
Advertisements
Question
Explain different types of inheritance with suitable diagram.
Solution
(1) The mechanism of deriving a new class from an old one is called as inheritance. The old class is referred as base class and new class is referred as derived class. C++ strongly supports the concept of reusability. This is basically done by creating new classes, reusing the properties of the existing ones. Functions and variables of a class that has been tested can be used by object of another class. This is known as inheritance.The reuse of a class that has already been tested, debugged and used many times, can save the efforts of developing and testing the same again.
(2) One of the most useful features of classes is inheritance. It is possible to declare a class that inherits the properties of another class or classes. This means that, with good class design, you can build applications, which are based on proven re-usable code. i.e. main purpose behind inheritance is code-reusability
(3) Different forms of Inheritance
1. Single inheritance
2. Multiple Inheritance
3. Hierarchical Inheritance:
4. Multilevel Inheritance
5. Hybrid Inheritance