michelle1278
Programmer
I have the following class hierarchy:
Class Base
{
void baseFoo();
//some more functions
private:
int baseIdx;
};
class Derived : public Base
{
void derFoo();
//some more functions
private:
int spvar;
};
then object of type Derived:
Derived derObj;
When I checked the memory layout of "derObj", the first 4 bytes of the object are reserved. The value of the int baseIdx starts at the 5th byte.
I cannot understand why those first 4 bytes are reserved, there's no virtual functions/ vtable involved in this class hierarchy.
Class Base
{
void baseFoo();
//some more functions
private:
int baseIdx;
};
class Derived : public Base
{
void derFoo();
//some more functions
private:
int spvar;
};
then object of type Derived:
Derived derObj;
When I checked the memory layout of "derObj", the first 4 bytes of the object are reserved. The value of the int baseIdx starts at the 5th byte.
I cannot understand why those first 4 bytes are reserved, there's no virtual functions/ vtable involved in this class hierarchy.