Sign in to follow this  

Member function pointers

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this