Spoiler alert: Maybe a stupid question. :)
#include <iostream>
using namespace std;
class Base
{
public:
virtual void YourMethod(int) const = 0;
};
class Intermediate : private Base
{
public:
virtual void YourMethod(int i) const
{
cout << "Calling from Intermediate" << i << "
";
}
};
class Derived : private Intermediate, public Base
{
public:
void YourMethod(int i) const
{
cout << "Calling from Derived : " << i << "
";
}
};
int main()
{
}
Can someone Explain to me why this throws the compiler warning:
main.cpp:21: warning: direct base a€?Basea€? inaccessible in a€?Deriveda€? due to ambiguity
Now, I understand that there is no way this code will work. I want to know why. Base
is private to Intermediate
so it should not be visible to Derived
through Intermediate
. So where does the ambiguity come from? In constructor?