Jump to content
  • Advertisement


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


C++ Function Pointer Question

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

I’ve just run into a C++ problem I haven’t encountered before using function pointers. I wanted to use a function pointer to call a public function in another class, and I’ve got something similar to the below code to set the function pointer: bool (COtherClass::*FuncPt) (int); if (Condition) FuncPt = COtherClass::Function1; else FuncPt = COtherClass::Function2; This compiles and links fine. The problem comes when trying to call the function pointer to by FuncPT because I don’t know the syntax to call it. I’ve tried all of the a few ways like the ones below but they all produce errors OtherClassObjPt->FuncPt(iIntvar); OtherClassObjPt->*FuncPt(iIntvar); OtherClassObjPt->(*FuncPt)(iIntvar); Can anyone tell me how to use function pointers to call a public function in another class? Thanks a lot. [edited by - mjones0 on October 18, 2002 10:52:59 AM]

Share this post

Link to post
Share on other sites
Original post by mjones0
Thanks a lost! I didn''t think to put the braces there

Parentheses. Braces are used for holding your trousers up.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!