January 2019
Intermediate to advanced
512 pages
14h 5m
English
In C++, a class can be derived from several base classes. Going back to our birds, let's make an observation—while flying birds have a lot in common with each other, they also have something in common with other flying animals, specifically, the ability to fly. Since flight isn't limited to birds, we may want to move the data and the algorithms related to processing flight into a separate base class. But there's also no denying that an eagle is a bird. We could express this relation if we used two base classes to construct the Eagle class:
class Eagle : public Bird, public FlyingAnimal { ... };
In this case, the inheritance from both base classes is public, which means that the derived class inherits both interfaces and ...