class student { ... }; class assistant { ... }; class student_assistant : public student, public assistant { public: student_assistant( int id, int sal ) : student(id), assistant(sal) {} };
Dynamic binding for instances of a class derived by multiple inheritance works in the same way as in the case of single inheritance. However, ambiguities between member function names must be resolved by the programmer.
class person { }; class student : virtual public person { ... } class assistant : virtual public person { ... } class student_assistant : public student, public assistant { ... };
To ensure that {\em student_assistant}
contains only one copy of the person
class, both the student and assistant
classes must indicate that the person
is inherited in a virtual manner.
Otherwise, we may not have a declaration of the form
person* p = new student_assistant(20,6777,300);