Hello.
In the main where i make a copy of above objects(bellow that comment) i don't know how to determinate what type the object it is so i wrote (a) for this example
[code]
class a
{
public:
virtual void Print();
};
class b : public a
{
public:
void Print();
};
class c : public a
{
public:
void Print();
};
//////////////////////////////////////////
void a::Print()
{
std::cout<<"a"<<std::endl;
}
void b::Print()
{
std::cout<<"b"<<std::endl;
}
void c::Print()
{
std::cout<<"c"<<std::endl;
}
//////////////////////////////////////////
int main()
{
std::unique_ptr<a> objA1 = std::unique_ptr<a>(new b);
std::unique_ptr<a> objA2 = std::unique_ptr<a>(new c);
//Make a copy of above objects
std::unique_ptr<a> objA3 = std::unique_ptr<a>(new a/*this a i do not know to to determinate its type*/(*objA1));
std::unique_ptr<a> objA4 = std::unique_ptr<a>(new a/*also this a i do not know to to determinate*/(*objA2));
objA1->Print();
objA2->Print();
objA3->Print();
objA4->Print();
system("pause");
return 0;
};
[/code]
Output is
b
c
a
a
But i need it to be (b c b c) how can i achieve that?