Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一本书中读到多态性是通过三个级别的指针(使用 vtable)在 c++ 中实现的,但是在 c++ 中还有其他实现它的方法。
虚函数也可以像这样用函数指针直接实现。
struct A { void (*foo)(A *thiz); void (*goo)(A *thiz, int x); };
但显然这比正常的实现效率低。实际上,在处理多重继承和虚拟基类时,C++ 实现可能会有所不同。
HTML 注释后的标签