Welcome to the 62nd tutorial on c++ program series and in this part we're gonna be looking at the multiple class inheritance feature. c++ allows a class to inherit from multiple classes in the previous part we looked at inheriting from a single class. c++ allows you to inherit from multiple classes. This is useful as you may have several classes that inherit from all the classes but only need certain properties. multiple inheritance allows you to group the properties essentially, together, inherit those group properties basically allows you to organize your code a little better, and this allows you to be more efficient at work a certain variable method you don't need to no point having them. So we'll create a class called vehicle.
Public speed, just got the hiccup safely Just class extra taught now in here we can do public boo blue doors and now we're going to do is create a new class to cold call and to inherit from more classes you do call on the open for the public. Then you put well both for the classes that you want to inherit from you vehicle info comma, the bulk public again. Well there's gonna be extra parts in this situation or whatever the name of your class ID and then in here, we're simply gonna have it's gonna have a nova variable is broken. Now what we can do is a semicolon there or we can do is create an object of this class of car BMW pm. pm the veto speed equals 200 bmw.is broken April's true BMW dot has to fold down this causes a BMW dot has exhaust.
Last fall into if C out you probably will be able to be the last first and always want to know we get a value of one is true we do have those real value zero folks activist group Should everybody have one cut it is broken and like it is true for b plus b we should get a value of 200. As you can see, even though called the vendor specifically have the variables declared here because it's inherited from these two classes you can inherit from more than two classes or classes inherit from these two classes. It's a okay and we have all it variables and methods so if we were to just create a method I will just create one for the sake of this tutorial on the void print function. This is implemented so void vehicle print function and an STD see out. There we're gonna do h h h h, e, basically STD Line changes to location.
Now if we just do be able to view print function on your neck, we get he printed out because of this inherited his method as well. So that's it for this part of this series. In the next part we'll be looking at virtual methods. If you have any questions feel free to message us or support us on our systems. That colleague email will be in the description. You can comment on this video which is directly messages for YouTube, or the required links.
The source code will also be in the description. And as usual, thanks for watching and I hope you have a great day.