Jump to content

how can i call a member function of class(sc_module) after finding a object using sc_find _object?


nikhil jain

Recommended Posts

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 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...