Here is an interesting problem I've come across. It's more on the use of some C++ design patterns.
Scenario: There is an interface. Sub-classes implement this interface. There is a manager that should iterate through these sub-classes and issue commands, etc.
Problem: How is it possible to register these sub-classes to the manager at compile time?
I have tried doing something like:
and let the manager iterate through classes. However, this means the manager will have no control over which subclass gets loaded into memory. How is possible to address a class without instantiating it? I realize this is kind of like reflective programming, and I don't mind templates in this case.
Thanks.
Scenario: There is an interface. Sub-classes implement this interface. There is a manager that should iterate through these sub-classes and issue commands, etc.
Problem: How is it possible to register these sub-classes to the manager at compile time?
I have tried doing something like:
Code:
typedef struct List { Interface * subclass; } List; List classes[] = { new Subclass1(); new Subclass2(); };
Thanks.
Comment