Why vptr is not static?

前端 未结 7 975
忘了有多久
忘了有多久 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 20:05

    The runtime class of the object is a property of the object itself. In effect, vptr represents the runtime class, and therefore can't be static. What it points to, however, can be shared by all instances of the same runtime class.

提交回复
热议问题