Inheritance by dominance - is it really bad?

前端 未结 3 1848
粉色の甜心
粉色の甜心 2021-02-12 12:02

I\'m one of those people that has to get their code to compile with 0 warnings. Normally I respect the compiler and if it issues me a warning I take it as a sign that I should t

3条回答
  •  日久生厌
    2021-02-12 12:18

    When performing virtual inheritance, it is a bad idea to not explicitly override every member in the most derived class. Else, you are asking for your code to die a horrible death when someone changes one of your base classes that inherits from the virtual base. There's nothing actively wrong with this, your program won't crash or anysuch, but it's a maintainability bad idea. If you want to call the Bar::foo version, then you should just delegate to it in Quux::foo.

提交回复
热议问题