Hey Laurens and Brad, > However, I want to use pure virtual functions > in my classes solely to specify a contract that subclasses must > abide to. The introduction of the "virtual" function is a "sufficient" condition for the compiler to defer the binding till run-time. It is you - the developer - who is saying that you will not be invoking the virtual functions on the base class pointers....but try to see it from the angle of the implementers of the compiler - they have no idea, whatsoever, how would the developer make use of the virtual functions - whether on base class poitners or derived class pointers. It just cannt be guaranteed. Consequently, the declaration of a function to be virtual introduces virtuality in the class.
> So, if your base class has 10 virtual functions and you derive 4 > classes from your base class you are consuming right around 160 + > 32 = 192 bytes. 160 bytes if it is assumed that none of the derived classes give a differnt implementation for the virtual functions. If they do, then the derived class vtable has to store two pointers for a given "overridden" virtual function - one pointer would be pointing to its base class implementation, and another entry would point to its derived-class implementation. So, if you give the implementation for all the virtual functions in all the derived classes, I guess the total bytes consumed would be 2*160=320 bytes. If the base class virtual function is a pure virtual function, then I guess the entry in the vtable for such functions points to address of something like __pure() functions(the name varies). Furthermore, I guess, the default implementation for __pure() is to throw an assert. I dunno what for the additional 8 bytes - as said by Brad - are allocated by Code Warrior but certainly in CFront implementation, the vtable also used to store the pointers to the base classes in the case of diamond inheritance. I mean the entry for the base pointers was in vtable itself. > I don't think there is an exception for pure virtual function > declarations, but I am not completely positive. As said above, for pure virtual functions, the entry does exist in vtable which points to a default implementation of __pure() function. Thanks. -Viren -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
