Hi,
Is it acually possible to get a new instance of a class with just a string name i.e. that is the name of the class ? I know I could use an object factory pattern to do this. Ofcourse this also means that I would have to inherit from every class from a base class - but does a method like this already exists in C++ ?
Thanks
Comments
: Hi,
:
: Is it acually possible to get a new instance of a class with just a string name i.e. that is the name of the class ? I know I could use an object factory pattern to do this. Ofcourse this also means that I would have to inherit from every class from a base class - but does a method like this already exists in C++ ?
:
: Thanks
:
:
I have a c++ program that can print one of 20+ different reports, each report is a c++ class whose base class is CReport. Pass the report function a std::string report name, the function uses a series of if statements and creates an instance of the class, then prints the report through that instance pointer. Microsoft MFC has another method using RUNTIME_CLASS, but I doubt that would be something you would want to emulate.