Where is the “virtual” keyword necessary in a complex multiple inheritance hierarchy?

后端 未结 7 1682
死守一世寂寞
死守一世寂寞 2021-01-30 19:00

I understand the basics of C++ virtual inheritance. However, I\'m confused about where exactly I need to use the virtual keyword with a complex class hierarchy. F

7条回答
  •  时光说笑
    2021-01-30 19:36

    On thing to keep in mind is C++ keeps a table of the inheritance. The more you add virtual classes, the longer will be compilation time (linkage) and the heavier would be the runtime.

    In general, if one can avoid virtual class, you can replace by some templates or try to decouple in some way.

提交回复
热议问题