I am developing an api for internal and external usage. On Visual Studio 10.
I have a virtual base class IA and a derived virtual base class IB. I implement IA with class A and then derive a concrete implementation for IB off of B. This to my understanding is the classic diamond problem. So I make A inheritance of IA virtual and the same for Bs inheritance of A. But I get a warning c4250 (warning C4250: 'B' : inherits 'A::A::AnInt' via dominance)
- while this warning seams to indicate the compiler is doing what I want I was uncomfortable with the warning and wanted to make sure it was safe to #pragma out, or there some issue I am not aware of.
The code
class IA
{
public:
virtual int AnInt() = 0;
};
class A : virtual public IA
{
public:
virtual int AnInt()
{
return 3;
}
};
class IB : virtual public IA
{
public:
virtual int AnInt2() = 0;
};
class B : public A, public IB
{
public:
int AnInt2()
{
return 4;
}
};
Second part of the question. If you are creating an api where the consuming developers will not be able to change the abstract classes in question. Should you avoid designing interfaces with inheritance or go ahead and make the derived classes utilize virtual inheritance.