B
billy
I've got a set of subclasses that each derive from a common base class. What
I'd
like to do is create a global array of the class types (or, class names)
that a manager
class can walk through in its constructor and instantiate one of each of the
class types
in this global array. So, it's almost like the global array has to hold data
types as
opposed to data. Basically, I currently have to add the items manually 1 at
a time.
I want to have the class names in a global array that I can walk through and
turn the
following code into a loop up to N_ELEMS(array) to avoid having to add one
of
these calls everytime I want to create a new OneOfTheObjectsIWantToAdd_N.
Also note that I don't have control over the addItem() member.
m_manager->addItem(
new SomeNameSpace::SomeClass<OneOfTheObjectsIWantToAdd_1>(
"Name Of The Object I Want To Add",
&OneOfTheObjectsIWantToAdd_1::MemberMethod));
m_manager->addItem(
new SomeNameSpace::SomeClass<OneOfTheObjectsIWantToAdd_2>(
"Name Of The Object I Want To Add",
&OneOfTheObjectsIWantToAdd_2::MemberMethod));
If I had an array of OneOfTheObjectsIWantToAdd_1 - _N, I think I could get
away with
putting the above code in a loop. The bottom line is that it is sort of like
building an array
of structure names and trying to malloc them at runtime based on their
names. Anyway,
thanks for any help.
~billy
I'd
like to do is create a global array of the class types (or, class names)
that a manager
class can walk through in its constructor and instantiate one of each of the
class types
in this global array. So, it's almost like the global array has to hold data
types as
opposed to data. Basically, I currently have to add the items manually 1 at
a time.
I want to have the class names in a global array that I can walk through and
turn the
following code into a loop up to N_ELEMS(array) to avoid having to add one
of
these calls everytime I want to create a new OneOfTheObjectsIWantToAdd_N.
Also note that I don't have control over the addItem() member.
m_manager->addItem(
new SomeNameSpace::SomeClass<OneOfTheObjectsIWantToAdd_1>(
"Name Of The Object I Want To Add",
&OneOfTheObjectsIWantToAdd_1::MemberMethod));
m_manager->addItem(
new SomeNameSpace::SomeClass<OneOfTheObjectsIWantToAdd_2>(
"Name Of The Object I Want To Add",
&OneOfTheObjectsIWantToAdd_2::MemberMethod));
If I had an array of OneOfTheObjectsIWantToAdd_1 - _N, I think I could get
away with
putting the above code in a loop. The bottom line is that it is sort of like
building an array
of structure names and trying to malloc them at runtime based on their
names. Anyway,
thanks for any help.
~billy