nikhil jain Posted January 15, 2019 Report Share Posted January 15, 2019 let's assume there are two classes , A and B and in sc_main i am creating the object of A "only" and in class B i am using sc_find_object(hierarchical name of A) then the result from sc_find_object is sc_object type but class A is sc_module so, i typecast-ed into sc_module but still i am not able to call the Api's of class A inside class B. below code is just psedo code . sorry if there is any mistake . it is just for explaining the scenario. sc_main { A obj=new A("objectA"); } class A: sc_core:: sc_module { public: void fun() { cout<<"Hello world"; } }; class B { public: void function() { sc_core::sc_object* obj = sc_core::sc_find_object("objectA"); sc_core::sc_module* ObjNew ObjNew = dynamic_cast<sc_core::sc_module*> (obj); ObjNew->fun() - i.e fun exist in class B . but it is showing error } }; please help Quote Link to comment Share on other sites More sharing options...
David Black Posted January 15, 2019 Report Share Posted January 15, 2019 dynamic_cast to sc_module* would only give you access to methods of sc_module that were overridden in A. fun() and function() are not part of sc_module. nikhil jain 1 Quote Link to comment Share on other sites More sharing options...
nikhil jain Posted January 15, 2019 Author Report Share Posted January 15, 2019 @David Black Thank you david it is working now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.