Jump to content
  • Advertisement

Archived

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

Pointer to a Function?

This topic is 5299 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

Is it possible to pass a name/pointer of a function through a method so that the method can call the function? Example:
int *foo()
{
    return 5;
}

int fooMethod(int *function())
{
    // Call the function passed through
    function();
    return 0;
}

int main()
{
    // Call the foo method passing through the foo function.
    fooMethod( foo() );
    return 0;
}
   
..... Is it possible to do that some how? I know this example seems a bit usless, but what I'm using it for would just make the program kick ass. [edited by - Rob Loach on November 17, 2003 10:06:18 PM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Namethatnobodyelsetook
Yes. Changed your sample to int from int *, since you''re not returning an int *... [ code ]
Also click here



Awesome! Thanks a lot!

Hmmm, they make it WAY more complicated then it actually is.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!