首先,Vee -Table指针用于访问虚函数,而对数据成员的访问直接使用编译时偏移量实现。
First, the Vee-Table pointer is used to access virtual functions, and data members are accessed directly using compile time offsets.
如果函数是虚函数,并且调用是通过引用或者指针,编译器基于动态类型生成代码确定调用哪个版本。
If the function is virtual and the call is through a reference or pointer, then the compiler generates code to determine which version to run based on the dynamic type of the object.
当你通过基类的指针来调用虚函数,技术也是一样的。
When you invoke calls through a pointer to the base class, the technique is the same.
这个函数允许客户端请求对象提供关于自己的其它方面的指针,这个新指针同样指向不同的虚基类(也叫做接口)。
This function allows a client to ask the object for different pointers to itself that also point to different abstract base classes (also known as interfaces).
内存开销非常小:基本上每个接口需要额外4个字节(对象实例数据里虚函数表指针),加上引用计数的4个字节。
Overhead in memory is very small: You basically have a 4- byte overhead per interface (the vtable pointers in the object's instance data) plus 4 bytes for the reference counter.
讨论值类型语义的更改,包括继承的虚方法、类默认构造函数、内部指针和钉住指针。
Discusses changes to value type semantics, including inherited virtual methods, class default constructors, interior Pointers, and pinning Pointers.
讨论值类型语义的更改,包括继承的虚方法、类默认构造函数、内部指针和钉住指针。
Discusses changes to value type semantics, including inherited virtual methods, class default constructors, interior Pointers, and pinning Pointers.
应用推荐