比如
class a
{
public:
virtual void fun1();
vitrual void fun2();
private:
int i;
}
class b : public a
{
public:
virtual void fun2();
virtual void fun3();
private:
int j;
}
则class a 的内存layout为(win32 platform)
begin of layout of class a
vtable pointer (pointer to vtable of class a see below) (4 bytes)
int i (4 bytes)
end of layout of class a
vtable of class a
begin of vtable of class a
start address of a::fun1 (4 bytes)
start address of a::fun2 (4 bytes)
end of vtable of class a
class b 的内存layout为(win32 platform)
begin of layout of class b
vtable pointer (pointer to vtable of class b see below) (4 bytes)
int i (4 bytes)
int j (4 bytes)
end of layout of class b
vtable of class b
begin of vtable of class b
start address of a::fun1 (4 bytes)
start address of b::fun2 (4 bytes)
start address of b::func3 (4 bytes)
end of vtable of class b