this is bothering me for a while...
what i want to achieve is that the same instance of the inherited class will have the same value of the parent class like so...
Code:
class A{
//ctor
//dtor
//cctor
//ator
...
};
class B : public A{
//ctor
//dtor
//cctor
//ator
...
};
class C : public A{
//ctor
//dtor
//cctor
//ator
B * b;
func(){
//OK... i achieve to have (explicitly?) convert C to A
A * a = new C(*this);
b = new B();
//Error... how would i copy? A to B
*b = (B)*a;
}
};
I would like to have class B to have the same values of class A as of those with class C. But i can't copy A to B, it says it could not find a match for B(A). how could i achieve this?
sorry if my terminologies maybe incorrect about explicit or implicit conversion... i'm still having trouble knowing which is which (as well as object slicing).
Thanks.
EDIT: forgot something