Visual Studio 2013.
Given:
class base_1
{
public:
virtual void foo(int) = 0;
};
class base_2
{
public:
virtual void foo(int, double) = 0;
};
class join_1_2 : public virtual base_1, public virtual base_2
{};
I have a sink:
void sink(join_1_2 ¶m)
{
param.foo(42, 3.14);
}
But I get the following compiler errors:
error C2385: ambiguous access of 'foo'
could be the 'foo' in base 'base_1'
or could be the 'foo' in base 'base_2'
error C2660: 'base_1::foo' : function does not take 2 arguments
error C3861: 'foo': identifier not found
I know I can resolve this issue with:
param.base_2::foo(42, 3.14);
But as you can imagine, virtual inheritance is already one sin too many I have to live with. I'm probably going to write an adapter. But I don't understand what is preventing the compiler from trying to resolve foo in base_2. My colleague believes it to be a compiler error, but I'm not so quick to blame the vendor.
What does the C++ spec say about resolving overloaded virtual methods across base classes?