I know this was asked many times but I could not found a suitable solution for my problem.
I have something like the following code:
#include <iostream>
#include "stdafx.h"
using namespace std;
class A //can not modify
{
public:
double ComputeValue(double val)
{
return val + 1;
}
};
class B : public A {}; //can not modify
class C : public A {};
class D : public B, public C {};
class E //can not modify
{
public:
double GetValue(A *a)
{
double x = 4;
return a->ComputeValue(x);
}
double DoSomething()
{
return GetValue(new D());
}
};
int main()
{
E *e = new E();
cout << e->DoSomething();
return 0;
}
I get the Error ambiguous conversion from 'D * to A *' in DoSomething. I know that I could solve this problem using "diamond inheritance". But I could not change class A or class B or class E because they already been used in a lot of location and a change like it is described in the diamond inheritance could produce problems in the application. So i can modify just class C or class D.
To clarify what I need to do is to make a new class inherited from A: C and to make class D inherit this new class without causing problems in F. I am looking in a method to block in class D the inheritance of A from C. Also to make class B inheriting from C or to modify B to do everything C is doing is not an option.