Answer the question
In order to leave comments, you need to log in
How to get rid of warning C4250: inherits via dominance?
Dear readers of habrahabr,
please help me with the following problem.
Let's say we have two interfaces:
class IA
{
public:
virtual int FuncA() = 0;
};
class ISuperA : virtual public IA
{
public:
virtual int FuncSuperA() = 0;
};
class A1 : virtual public IA
{
public:
virtual int FuncA() { return 1; }
};
class AIncrement: virtual public ISuperA
{
public:
virtual int FuncSuperA() { return (FuncA() + 1); }
};
class A1Increment: virtual public AIncrement, virtual public A1
{
};
int main()
{
A1Increment a;
cout << "test: " << a.FuncSuperA() << endl;
}
Answer the question
In order to leave comments, you need to log in
If you don't want to suppress the warning, you can tell the compiler explicitly:
class A1Increment: public AIncrement, public A1
{
virtual int FuncA()
{
return A1::FuncA();
}
};
About warning one and two . You can remove it with the warning pragma .
GCC and Clang didn't show any warning.
class AIncrement: virtual public ISuperA
class A1Increment: virtual public AIncrement, virtual public A1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question