How Vtable of Virtual functions work

后端 未结 3 1397
离开以前
离开以前 2021-01-13 17:58

I have a small doubt in Virtual Table, whenever compiler encounters the virtual functions in a class, it creates Vtable and places virtual functions address over there. It h

3条回答
  •  旧巷少年郎
    2021-01-13 18:31

    Whenever the program compiles the virtual table for each class is created, which makes clear to the fact that vtables are created per class basis. During run time, when the object is created the compiler assigns vptr to the object, which points to the virtual table for the particular class' object. In short the vptr is created per object basis.

提交回复
热议问题