Technical Notes Database
TN449D.txt CONSTRUCTOR CALL TO ANCESTOR WITH VIRTUALS
Category :Pascal
Platform :All
Product :Turbo Pascal 5.5
Description:
Q. If a descendant of a virtual object defines no virtual
methods of its own, does it need to call the ancestor's
constructor?
A. If an object is a descendant of a virtual object, it must call
that ancestor's constructor or it's own constructor. Even if
the new object does not define any virtuals of its own. For
example:
Type
A = Object
Constructor Init;
Procedure AA; Virtual;
End;
B = Object ( A )
End;
For each instance of A and of B, Init must be called or the
Virtual Method Table pointer will not be loaded correctly.
Reference:
7/16/98 4:35:32 PM
Last Modified: 01-SEP-99