Multiple inheritance
So far we have used inheritance to mean deriving a new class from a single parent. It is possible to
build a sub-class from more than one parent, so that it inherits the attributes of all of them. So long
as there are no name conflicts in the parents, the sub-class can simply be thought of as inheriting all
attributes of all parent classes.
class a {
public:
int i;
};
class b {
public:
float j;
};
class c : public a, public b {
int k;
};
Where the same name occurs in two or more parent classes, the use of class name qualification can
be used to resolve the ambiguity.
Next note in series
Back to index