Hi there!
Are there any equivalent functions in C++ that is similar to clone() in Java?
In VC++,
I have 2 vectors with different types namely,
std::vector<Cla ssA *> v1;
std::vector<Cla ssB *> v2;
Is there anyway that i can assign v2 to v1 given that the vectors are of different types?
I know it is easy in Java, since at the initial declaration of the vectors, you don't
have to supply what type of objects are to be inserted.
Ex.
Vector v1 = new Vector();
Vector v2 = new Vector();
ClassA a = new ClassA();
v1.add(a);
ClassB b = new ClassB();
v2.add(b);
v2 = (Vector) v1.clone();
Any suggestions?
Thanks very much.
Are there any equivalent functions in C++ that is similar to clone() in Java?
In VC++,
I have 2 vectors with different types namely,
std::vector<Cla ssA *> v1;
std::vector<Cla ssB *> v2;
Is there anyway that i can assign v2 to v1 given that the vectors are of different types?
I know it is easy in Java, since at the initial declaration of the vectors, you don't
have to supply what type of objects are to be inserted.
Ex.
Vector v1 = new Vector();
Vector v2 = new Vector();
ClassA a = new ClassA();
v1.add(a);
ClassB b = new ClassB();
v2.add(b);
v2 = (Vector) v1.clone();
Any suggestions?
Thanks very much.
Comment