Why vptr is not static?

前端 未结 7 981
忘了有多久
忘了有多久 2020-12-28 19:27

Every class which contains one or more virtual function has a Vtable associated with it. A void pointer called vptr points to that vtable. Every object of that class contain

7条回答
  •  春和景丽
    2020-12-28 19:57

    virtual method table is per class. An object contains a pointer to the run-time type vptr.

    I don't think this is a requirement in the standard bust all compiles that I've worked with do it this way.

    This is true even in you example.

提交回复
热议问题