Search code examples
c++vtable

Virtual Table layout in memory?


how are virtual tables stored in memory? their layout?

e.g.

class A{
    public:
         virtual void doSomeWork();
};

class B : public A{
    public:
         virtual void doSomeWork();
};

How will be the layout of virtual tables of class A and class B in memory?


Solution

  • As others have said, this is compiler dependant, and not something that you ever really need to think about in day-to-day use of C++. However, if you are simply curious about the issue, you should read Stan Lippman's book Inside the C++ Object Model.