let’s say I have 200 classes named class1, class2, etc derived from class, and a integer between 1 and 200. Is there a way to instanciate specifically one of the derived class depending on the value of my integer? Obviously I could just manually check for every value but I am wondering is there is anything in C++ that is more flexible
Share
You will have to do a switch on your integer, and instantiate the specific class. If you have this
int->classlogic somewhere else in your program, you could consider representing it with a compile-time map. Look at Boost.MPL, specificallyboost::mpl::map.