 Hello everyone, I am Mrs. Meenakshi Srikanthi, Assistant Professor from Walchand Institute of Technology, Sholapur. Welcome to the video lecture on multiple inheritance. Learning outcome. At the end of this session, students will be able to explain and write program using multiple inheritance. Let us see what is inheritance. Here a set of definitions are given where it will explain what is meant by inheritance. So here it is the capability of one class to inherit the properties from another class. The technique of building new classes from the existing classes is called as inheritance. The mechanism of deriving a new class from the old class is called as inheritance. The old class is referred as the base class and the new class is called as the derived class. So here it shows a structure for inheritance where it contains a base class from which the properties from the base class are inherited into the derived class. Let us see what is a base class and a derived class is. A base class is a class whose properties are inherited by another class. A base class is also called as a superclass. Derived class is a class which inherits the properties from the base class. The derived class is also called as a subclass. Here it shows a base class which is also called as a superclass. The properties of the base class are inherited into the derived class which is also called as a subclass. A derived class can inherit some or all the features of the base class and can add additional features to the derived class. So a derived class is not only inheriting the properties from the base class but also it has its own feature. So the combination of the features of itself as well as the features which are inherited from the base class will give the total members of the derived class. Let us see the types of inheritance. Single inheritance, a derived class with only one base class is called as a single inheritance. So here it shows a structure where we have a single base class and a single derived class. Multiple inheritance, a derived class with several base classes is called as multiple inheritance. So here a derived class has been derived from more than one class is called as multiple inheritance. So in this example class C has been derived from class C and class B. Hierarchical inheritance, in this the threads of one base class are inherited by more than one derived class. So here from one base class more than one derived class has been derived such a structure is called as hierarchical inheritance. Multilevel inheritance, the mechanism of deriving a new class from another derived class is called as multilevel inheritance. So here it shows an example of multilevel inheritance where class B has been derived from class A and class C has been derived from class B. So class A is called as a superclass or base class, class B is called as an intermediate base class and class C is called as a derived class. Here the levels are too but it is not always fixed we can increase the levels also. The last type of inheritance is called as a hybrid inheritance. It is a combination of more than one type of inheritance. So we have already seen the four basic types of inheritance. Those are nothing but single, multiple, hierarchical and multilevel inheritance. And hybrid is an inheritance where it's a combination of the basic types of inheritance. So this shows the structure of hybrid inheritance but this structure is never fixed because here we can we can change the combination of inheritance. In this example we have two combination the upper part if you see this will give the hierarchical inheritance and if you consider the bottom part it will give the multiple inheritance. Let us see the third type of access specifier which is called as protected access specifier. A protected member of the base class cannot be inherited and so not directly accessible to the derived class. So as we already know a private member is only visible to the member functions of the same class and they are not inherited. But at some places if I want to access the private data and if that private data is made as public this would make it accessible to all of the functions of the program thus taking away the advantages of data hiding. So here the public members we already know that it is visible to all the functions in the program. So if the private data is made as public it is not only accessible within the class but it will be accessible to all the functions outside the class also. That's why it will lose the advantage of data hiding. A third visibility modifier is there that is called as protected which serve a limited purpose in inheritance. So a protected visibility label is there but it serves a limited purpose in inheritance. A protected access specifier a member which has been declared as protected is accessible by the member functions within its class and any class immediately derived from it. It cannot be accessed by the functions outside these two classes. So a protected member it is visible to the member functions of its own class and that of the derived class but these are not accessible from the main function like a private data. Let us see how to define a derived class. A derived class can be defined by specifying its relationship with the base class in addition to its own details. So it can be specified by using the syntax where we have a keyword called as class followed by that is the name of the derived class. After that we have a colon and here we are mentioning the mode of the visibility that is the mode of derivation and after that we have to mention the name of the base class. Here the mode of derivation is there that is the visibility mode. Here there are three types of mode of derivations are there those are public, private and protected. Let us see the modes of derivation. So let us see the first type of derivation that is private derivation and the private mode of derivation. The public members of the base class become private members of the derived class. The protected members of the base class become private members of the derived class and Private members of the base class are not inherited. So here it shows the base class has been defined and the derived class has been defined with private mode of derivation. Here we have to mention the private visibility label. Derived class can also be defined in this way where no visibility label is mentioned here but still by default it is considered as private derivation. The next mode of derivation is the public mode of derivation. Under public mode of derivation the public members of the base class become public members of the derived class. Protected members of the base class become protected members of the derived class and private members of the base class are not inherited. So this is how the base class has been defined and the derived class has been defined in this way where it is mentioning the mode of derivation as public. The last type of derivation is called protected mode of derivation. Under protected mode of derivation, the public members of the base class become protected members of the derived class and protected members of the base class become protected members of the derived class and private members of the base class are not inherited. So here it shows the base class has been defined and the derived class has been defined with protected mode of derivation. So here it shows the visibility of the inherited member under different mode of derivation. Try to think and answer what are the advantages and disadvantages of inheritance. Pause the video for some time and note down the answer in your book. Advantages and Disadvantages of Inheritance Advantages of Inheritance Inheritance promotes core reusability when a class inherits or derives another class it can access all the functionality of the inherited class. Because of this the size of the code is minimized. Disadvantages of Inheritance Inherited functions work slower than the normal functions as there is in direction. Often data members in the base class are left unused which may lead to memory wastage. In this video we are going to focus on multiple inheritance. So let us see the definition again. So in multiple inheritance a derived class with several base classes is called as multiple inheritance. That means there is only one derived class that is the subclass and more than one base class that is superclass. So here it shows a structure where we have more than one base class from which we are deriving a new class that is a single derived class. Let us see an example using multiple inheritance. There is a class called as x and a protected visibility label there is a data member called as x and under public visibility label there is a member function called as get coordinate where it assigns the parameter a to x. So this is a base class which has been defined. There is one more class called as y and the protected visibility label there is a data member called as y and under public visibility label there is a member function called as get coordinate and there is a parameter b where this function will assign the parameter b to y. So the base class has been defined here. There is a class called as coordinate which has been inherited from class x as well as y under public mode of derivation. So this is a derived class which has been defined with public mode of derivation for both the base classes. Now under public mode of derivation all the public members of the base class become public members of the derived class and the protected members of the base class become protected members of the derived class. So protected members of these two base classes become protected and the public members of these two base classes become public and the public visibility label it contains a display function where it displays the x and y coordinate of the base classes that is a derived class is accessing the members of the base class. Main function we are creating the object m and by using this object and the class x, we are accessing the get coordinate function. This is because the get coordinate function is present in both the base classes. Only mentioning get coordinate function will not work. So here we have to mention the class name and a scope resolution operator to access the get coordinate function of the class x where it will assign to val to the data member x. Similarly we are calling the get coordinate function of the class y by using the class name y and scope resolution operator and we are passing 24 to the member function get coordinate where it will assign this parameter 24 to y and after that we are calling the display function where it will display the coordinates of x and y. Let us see one more example using multiple inheritance. There is a class called as student and under protected visibility label there is a data member called as role and under public visibility label there is a member function called as get role where it will assign the value of x to role. So here the base class has been defined there is one more base class called as marks and under protected visibility label there are two data members subject one and subject two and under public visibility label there is a member function called as get marks where the value of x and y are assigned to subject one and subject two. So a base class has been defined here. Now from this two base class a class result has been derived from class student and from class marks it has been derived under public mode of derivation. So a derived class has been defined with public mode of derivation for both the classes. Under public mode of derivation all the public members of the base classes become public members of the derived class and all the protected members of the base class become protected members of the derived class. And hence a data member called as total and a member function called as display where it totals the subject marks and where it displays a role number that is it is a derived class is accessing the members of the base class. After that it displays the total marks also and in the main function first we are creating the object for the class and by using the object and the dot operator first we are calling the get role function where 12 will be assigned to the role and after that we are calling the get marks function where 74 and 84 are assigned to subject one and subject two. After that we are calling the function called as display where it displays the role number and the total marks. These are my references. Thank you.