#include #include "typefactory.h" #include using namespace std; int main() { cout << "Hello World!" << endl; struct Base { virtual ~Base() = default; virtual int get() = 0; }; struct Derived1 : Base { explicit Derived1 (int start) : m_start (start) {} int get() override { return m_start + 1; } int m_start = 0; }; struct Derived2 : Base { explicit Derived2 (int start) : m_start (start) {} int get() override { return m_start + 2; } int m_start = 0; }; TypeFactory factory; factory.registerType ("one"); factory.registerType ("two"); auto a = factory.create ("one", 10); auto b = factory.creator ("two") (10); // advanced API: get creator function (void)a->get(); (void)b->get(); return 0; }