[ fromfile: inheritance-detail-questions.xml id: inheritance-detail-questions ]
What is a vtable?
It is a virtual jump table - it can be implemented as a list of pointers to all methods (virtual functions) of a class.
What is a polymorphic type?
A class with at least one virtual
function. A class which has a vtable.
Which kinds of member functions are not inherited? Why?
They are copy constructors, copy assignment operators, and destructors. It is not appropriate to inherit these methods because they must perform operations on each member of the derived class, and the base class knows nothing about derived class types. Each of these functions are auto-generated for classes which do not supply one.
Under what circumstances should you have virtual
destructors?
When operating on a collection of polymorphic types, as long as there is one method, there should be a virtual destructor.
What happens when a virtual
function is called from a base class constructor?
Dynamic binding does not happen. The compiler will resolve the call at compile time, meaning that the derived override will never be called from a base class constructor.
What is virtual
inheritance? What problems can it be used to solve?
virtual inheritance makes it possible to avoid multiply-inheriting the same class, when it appears as more than one base's base class.
Why would you use nonpublic derivation?
It is very similar to having a non-public subobject, but it becomes possible to inherit methods that are only accessible in the class itself (and derived classes, if it is protected derivation)
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |