When is VTable in C++ created?

前端 未结 2 1373
花落未央
花落未央 2020-12-09 12:02

I would like to know when is a vtable created? Whether its in the startup code before main() or is it at some other point of time??

2条回答
  •  孤街浪徒
    2020-12-09 12:56

    A vtable isn't a C++ concept so if they are used and when they are created if they are used will depend on the implementation.

    Typically, vtables are structures created at compile time (because they can be determined at compile time). When objects of a particular type are created at runtime they will have a vptr which will be initialized to point at a static vtable at construction time.

提交回复
热议问题