Is there any penalty/cost of virtual inheritance in C++, when calling non-virtual base method?
There may be, yes, if you call the member function via a pointer or reference and the compiler can’t determine with absolute certainty what type of object that pointer or reference points or refers to. For example, consider: void f(B* p) { p->foo(); } void g() { D bar; f(&bar); } Assuming the call to … Read more