Inheritance

Mrs. Ignisha Rajathi

± C++ strongly supports the concept of reusability. . ‡ It is always nice if we could reuse something that already exists than trying create the same all over again.Inheritance ‡ Reusability is yet another important feature of OOP.

.Inheritance ‡ The mechanism of deriving a new class from an old one is called inheritance (or derivation). ± Old class Base class ± New class Derived class or sub class ‡ Derived class inherits some or all the traits from the base class.

Inheritance ‡ Various forms of Inheritance: ‡ ‡ ‡ ‡ ‡ Single Inheritance Multiple Inheritance Hierarchical Inheritance Multilevel Inheritance Hybrid Inheritance .

Inheritance ‡ Single Inheritance (Derived class with only one Base class ) A Base Class B Derived class .

Inheritance ‡ Multiple Inheritance Two Base Classes A B C Derived class ‡ One or more base classes .

Inheritance ‡ Hierarchical Inheritance ± [traits of one class may be inherited by more than one class (derived class)] A B C D .

Inheritance ‡ Multilevel Inheritance (deriving a class from already derived class) A B C .

Inheritance ‡ Hybrid Inheritance A B C D .

Inheritance .