I expected the offset of member m_RecordSize to be zero for both classBase and classDerived in the following but instead m_RecordSize is at offset 4 within classDerived. Is this due to the vtable in classDerived
For what it is worth, the reason this is important is because I have many more classes derived from classDerived that I am writing to disk so I need to ensure I understand the format of the data in memory. Everything else is working; packing is not a problem and such.
class classBase {
public:
classBase() : m_RecordType(Function_Unknown), m_RecordSize(0),
m_ReturnCode(0), m_Time(0) {};
size_t m_RecordSize;
unsigned _int64 m_Time;
DWORD m_ReturnCode;
enum enumRecordType {
Function_Unknown,
Function_Begin,
Function_End,
Function_Message,
} m_RecordType;
};
class classDerived : public classBase {
public:
classDerived();
virtual ~classDerived() {};
LPVOID m_p;
static const size_t InternalDataSize;
};
class classLogger {
public:
void Put(const classDerived *);
};
void classLogger::Put(const classDerived *pd) {
// &pd->m_RecordSize is 4 bytes greater than pd
};