differentiate the derived getdata() and display() from the defined getdata() and display() :: (scope resolution) operator is given along with the base class name to the base class members Note When a derived class member function has the same name as that of its base class member function ,the derived class member function shadows/hides the base class’s inherited function .This situation is called function overriding and this can be resolved by giving the base class name followed by :: and the member function name. • The mechanism of deriving new class from an existing class is called inheritance. • The main advantage of Inheritance is it supports reusability of code. • The derived class inherits all the properties of the base class.
It is a power packed class, as it can add additional attributes and methods and thus enhance its functionality. • The various types of Inheritance are Single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance and hybrid inheritance • When a derived class inherits only from one base class, it is known as single inheritance • When a derived class inherits from multiple base classes itis known as multiple inheritance • When a class is derived from a class which is a derived class itself – then this is referred to as multilevel inheritance. The transitive nature of inheritance is reflected by this form of inheritance. • When more than one derived classes are created from a single base class , it is known as Hierarchical inheritance.
• When there is a combination of more than one type of inheritance, it is known as hybrid inheritance. • In multiple inheritance, the base classes are constructed in the order in which they appear in the declaration of the derived class. • A sub-class can derive itself publicly, privately or protectedly. • The private member of a class cannot be inherited .
• In publicly derived class,the public members of the base class remain public and protected members of base class remain protected in derived class. • In privately derived class, the public and the protected members of the base class