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

后端 未结 7 1692
死守一世寂寞
死守一世寂寞 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:38

    If you want to have only one "physical" instance of each type for each instance of each type (only one A, only one B etc.) You'll just have to use virtual inheritance each time you use inheritance.

    If you want separate instances of one of the types, use normal inheritance.

    0 讨论(0)
提交回复
热议问题