//Instead of:
switch(class_type)
{
case type_1:
SubClass_1 obj = new SubClass_1();
case type_2:
SubClass_2 obj = new SubClass_2();
case type_3:
SubClass_3 obj = new SubClass_3();
case type_4:
SubClass_4 obj = new SubClass_4();
case type_5:
SubClass_5 obj = new SubClass_5();
}
//I just want to use a single line like this:
BaseClass obj = new (getClass(class_type))();
A factory pattern would work nicely here. Basically you have a abstract class for a factory that will be your interface, then you just have to create different subclasses for that abstract class for all the objects.
I guess there's no shorter way to create the dynamic class.
C++ isn't a dynamic language, the language doesn't provide a way to do it, either way it isn't *magic* for dynamic languages. They still need to find the class and such it's simply a matter of you implementing the method you want to do that.