Jump to content
  • Advertisement
Sign in to follow this  

Member function pointers

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

Greetings, Using C++/MSVS 2005 Express. I've got a class where I want to be able to call a multitude of different member functions based on certain conditions. I want to avoid a massive switch statement and use function pointers. Most of the examples I've googled for have shown have to create and use member function pointers, but not within the class that contains the member function. Example:
class Foo

      void Bar();

      void (Foo::*funcPtr)(void);

   funcPtr = &Foo::Bar; // <-- This compiles ok.
   (*funcPtr)(); // <-- Cannot get this syntax correct.
Thanks in advance.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!