Consider this:When I try to assign A a = d I get ambiguity. This is because d can be upcasted to B then A or to C then A. I'm trying to remove the ambiguity with a user-defined conversion, but it's not working. The complier always states ambiguity (MSVC++6.0). How can I slove this? Is the convertion operator well written??Code:class A{
public: A(){}
};
class B: public A{
public: B(){}
};
class C: public A{
public: C(){}
};
class D: public B,public C{
public: D(){}
operator A(){
return *static_cast<B*>(this);
}
};
int main(){
D d;
A a = d;
return 0;
}
EDIT:
If I write a C style casting will it be treated as static_cast or dynamic_cast ?