#include <iostream>
using namespace std;
class X {
public:
X(int)
{
cout << "X()" << endl;
}
void f()
{
cout << "f()" << endl;
}
};
class Y: public X {
public:
Y(int): X(1)
{
cout << "Y()" << endl;
}
};
class Z: public X {
public:
Z(int): X(1)
{
cout << "Z()" << endl;
}
};
class A: public Y, public Z {
public:
A(int): Y(1), Z(2) {}
using Y::f;
};
int main()
{
A a(2);
a.f();
}
Why when I call f() in main() i get this error. What is wrong ?
error: ‘X’ is an ambiguous base of ‘A’