I've never used multiple inheritance in C++ before, but i got curious since i've seen an implementation of a braided bst, by means of a multiple inheritance of a base class List and a base class BinarySearch tree in a book.
Now i was trying to make up some stupid example in order to understand how it works.
So i came up with this:
class Base1 {
public:
virtual void method();
};
class Base2 {
public:
virtual void method();
};
class Derivate : public Base1, Base2 {
};
In the main i've done something like this:
Derivate d;
d.method();
The code doesn't compile, there's other code which implements both methods, but i don't post all the code because i think i make my point anyway.
To me it sounds fair that it doesn't compile because probably it isn't known which method specifically the derivate class should refer to, however it could happen that two base classes i want to extend actually shares a method name (think to both list and bst you can have a method both a method "insert" and "delete") so in general how for this "critical cases" the multiple inheritance works? in case like the one i presented is there a way to solve in a elegant way the problem?