Hello everyone,
I think compiler is too strict in this case. You can see, no data member, no virtual function.
I am using Visual Studio 2008. The compiler error is simply because of Diamond pattern -- duplicate base class? Actually from logical point of view, there should be no ambiguity issue.
Any ideas?
Code:#include <iostream>
using namespace std;
class Base {
public:
int foo() {cout << "Base" << endl;}
};
class Derived1: public Base
{
public:
int foo() {cout << "Derived1" << endl;}
};
class Derived2: public Base
{
public:
int foo() {cout << "Derived2" << endl;}
};
class Final: public Derived1, public Derived2 {
public:
int foo() {cout << "Final" << endl;}
};
int main()
{
Final f;
Final* p = &f;
Base* pb = p; //error C2594: 'initializing' : ambiguous conversions from 'Final *' to 'Base *'
return 0;
}
thanks in advance,
George