Why virtual inheritance is not used as default? Default as in by the programmer and not the language.

If not, why? What are the cases where it may fail? Is there some run time overhead? Is it significant?

The motivation of this question comes from Stairway to heaven pattern. Its usage is not completely transparent, because of the use of virtual inheritance. If virtual inheritance was the default behaviour, it could have been used transparently. I am not saying it should be virtual by default because of this pattern.

closed as too broad by gnat, Doc Brown, Ixrec, Robert Harvey, user40980 Jan 22 '16 at 3:38

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    In C++ the mantra normally is "don't pay for what you don't use". I.e., if you don't need virtual functions, don't use them and that means you don't have to pay for them. To answer how significant it is, you could try building two programs that differ only in this regard, and measure performance differences. – Brandin Jan 19 '16 at 7:15
  • 1
    @Brandin the question is about virtual inheritance not virtual function – q126y Jan 19 '16 at 7:17
  • 1
    @q126y Same answer applies to virtual inheritance – Brandin Jan 19 '16 at 7:25
  • 6
    Virtual inheritance does add overhead to your program and is only useful in the rare case that you have multiple inheritance with a diamond pattern. Why would you use something as default that adds no benefit to your code? – Bart van Ingen Schenau Jan 19 '16 at 7:33
  • 2
    Given that diamond inheritance is a rarity, I don't think you have to look any further for your answer. It's not an industry-standard default because it's not commonly used. – Robert Harvey Jan 19 '16 at 22:54