コード例 #1
0
ファイル: main.cpp プロジェクト: hottaro/dynamic_create_class
int main() {
    
    // add. step <3/3>
    dynamic_add(MyLogic);
    
    
    DynamicBase *obj;
    
    // get, class. of course we can get from where didn't know Mylogic class except its base class.
    // @see line:18
    dynamic_get(std::string("Mylogic"), obj);
    
    if (obj) {
        // here is the point, we just know the base class. Logic.
        Logic *lc = (Logic*)obj;
        
        lc->do_something(); // here, -----> will call really_do_something() in Mylogic class, where we didn't know the class name. MyLogic.
    }
    
    // very simple, have fun.
    
    reutnr 0;
}