J
Julian
Hi,
I have a vector defined like this:
std::vector<Load*> LoadList;
which is populated with different objects of classes that are derived from
'Load'.
I need to make a copy of this list during runtime.
I imagine I'd have to loop through the list, make a copy of each of the
objects in the vector using the copy constructor... but I don't know the
class name during run time so that I can call the appropriate copy
constructor.
actually, I read up on 'typeid' which I supposed would give me the class
name... but I am still confused as how I can call the appropriate copy
constructor for that class during run time.
One option would be to do a string compare of the class names... but that
requires for me to be aware of all the classes derived from 'Load'.
Is there some other way to go about this?
thanks,
Julian.
I have a vector defined like this:
std::vector<Load*> LoadList;
which is populated with different objects of classes that are derived from
'Load'.
I need to make a copy of this list during runtime.
I imagine I'd have to loop through the list, make a copy of each of the
objects in the vector using the copy constructor... but I don't know the
class name during run time so that I can call the appropriate copy
constructor.
actually, I read up on 'typeid' which I supposed would give me the class
name... but I am still confused as how I can call the appropriate copy
constructor for that class during run time.
One option would be to do a string compare of the class names... but that
requires for me to be aware of all the classes derived from 'Load'.
Is there some other way to go about this?
thanks,
Julian.