I have the following struct and classes.
RefCounted has a virtual destructor, UnitHeader and Header are POD structs.Code:class RefCounted { private: LONG m_nRefCount; public: virtual ~RefCounted(); }; struct Header { short us; int i1; int i2; }; struct UnitHeader: public Header { BYTE filler[sizeof(ULONG) - (sizeof(_SUnitHeader) & (sizeof(ULONG) - 1))]; }; class CHeader : public UnitHeader, public RefCounted { };
CHeader inherits from UnitHeader and RefCounted.
Now consider this:
The 'this' pointer in CHeader is casted to UnitHeader struct and that memory area set to zero.Code:void CHeader::MakeDummy() { memset((UnitHeader*)this, 0, sizeof(UnitHeader)); }
Is that safe? Can I be sure that the Vtbl is not set to zero?



LinkBack URL
About LinkBacks


