• Advertisement

Archived

This topic is now archived and is closed to further replies.

How can i use a global function in a class?

This topic is 5777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can i use a global function in a class? And how can i use function pointer to point a global function in a class? Thanks

Share this post


Link to post
Share on other sites
Advertisement
What do u mean a global function, do u mean one defined in another class or part of the program away from ur code. If u mean a function defined in your class then u just give the name for example


suppose the class Test exists


  
void Test::function ()
{
// call another function in my class Test

Test::function2();
// or call it by this

function2();
// or by ''this''

this->function2();
}



has for pointers to functions I cannot really remember how to do that


Hope I have helped in anyway


calling a function from another class or ur main program with your function, I dont really know how try calling it the normal way by including the header of the source file it exists in

Dark Star
UK

Share this post


Link to post
Share on other sites
Global functions can be called from everywhere, you just need to include the file where the prototype is defined

Share this post


Link to post
Share on other sites

  • Advertisement