Lesson 22 - Advanced Inheritance in C++
In the previous lesson, Exceptions in C++, we looked at exceptions. Today, in the C ++ tutorial, we're going to talk about advanced inheritance techniques, such as private and multiple inheritance.
Private and Protected Inheritance
Until now, we used the
public keyword to inherit from a class.
We already know how this keyword works for a long time. If we use the
private keyword instead, then all the
protected members of the class we inherit from become
private. Members are both methods and fields. A class can use
protected fields and methods of the base
class in its own methods, but we cannot access them from outside or from derived
classes. In principle, we can imagine that with
protected members are
private. However, we still do not have access to
private members of the base class (the one we inherit from).
Protected inheritance works similarly.
public is replaced by
...End of the preview...
ict.social is a large database made up of manuals and tutorials, whose main goal is to provide high-quality IT education to everyone. We started out in the Czech republic, where we display roughly a million articles per month and receive plenty of gratitude from our users. Thanks to our successful establishment, we are now bringing these articles to the rest of the world.
Although we are trying to keep our content free of charge, maintaining the site is a huge effort for everyone involved. Therefore, some content (exercises and more advanced material) costs network points. Don't worry, they're really cheap :)
Requested article covers this content:
In this tutorial, we'll discuss advanced techniques of inheritance such as multiple inheritance and what problems it brings.
Buying this article gives you unlimited access to it forever. You will learn some more and help us keep giving our site maintenance which helps you and others get better futures. It's a win-win.
You gain points by supporting our network. This is done by sending a helpful amount of money to support the site, or by creating content for the network.
You can get points immediately using:
|Credit card||SMS||Wire transfer|