Do all classes have a Vtable created for them by the compiler?

后端 未结 3 1718
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 23:15

There are many resources online about VTables. They commonly have the same statement regarding them:

\"Whenever a class itself contains virtual functions or ove

3条回答
  •  终归单人心
    2021-01-12 23:54

    Actually, nothing in C++ requires that any class has a vtable - it's entirely an implementation issue. However, a class with virtual functions must somehow support polymorphic function calls, and this will always require a table/map of some sort. This table/map will be created by the compiler for classes that have polymorphic functions, and might (depending on compiler quality) be created for those that don't.

提交回复
热议问题