同时会添加一个虚指针到这个虚表里面,当调用虚函数时,对象通过虚指针(virtual pointer)找到虚表,然后遍历虚表,找到和这个函数同名的函数指针,函数指针指向这个虚函数的入口地址,从而将虚函数调起。
基于12个网页-相关网页
首先,Vee - Table指针用于访问虚函数,而对数据成员的访问直接使用编译时偏移量实现。
First, the Vee-Table pointer is used to access virtual functions, and data members are accessed directly using compile time offsets.
有一个为每个类的虚表,其中包含每个成员的功能的实现的指针列表。
There's a virtual table for each class, which contains a list of Pointers to the implementation of each member function.
每个对象都有一些附加字节,通用语言运行库用来管理对象,如对象的虚表指针和同步锁定引用。
Every object has some additional bytes that the common language runtime USES to manage the object, such as the object's virtual table pointer and a reference to a sync block.
应用推荐