In C++ multiple inheritance with virtual base i understand why could this code be ambiguous , but why it still complains when i specifically call a derived class method ?
class A {
public:
virtual void f() { cout << 1 ;}
};
class B :virtual public A {
public:
virtual void f() { cout << 2; }
};
class C :virtual public A {
public:
virtual void f() { cout << 3; }
};
class D : public B, public C {};
void main(){
D* d = new D();
d->B::f();
getch();
}
i would expect that it will run the B:f() method but i get : "ambiguous inheritance of 'void A::f(void)'
Diamond Inheritance Problem.. en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problemmainin C and C++ is NEVERvoid. Please change it to returnint. It really bothers me seeing this.