Couldn\'t the diamond problem be resolved just by using the first inherited declaration found? I mean,
public class A { public virtual int getInt(); }; public cl
This is not a diamond problem. C++ compiler is specific about all its syntax, if there is any ambiguity it will always throw error.
Here your A::getInt()
, B::getInt()
and C::getInt()
are ambiguous when you call simply d.getInt()
.
Edit:
In your edited question, still compiler doesn't evaluate from the inheritance, because some programmers may really need to have different copies of A
==> 1st via class B
and 2nd via class C
. Note that so called diamond problem is a problem characterized by humans. For C++ compiler, it's just one more pattern.
In C++ philosophy, you are not restricted to only one paradigm or pattern. You can choose to have multiple inheritance of your choice.