Skip to content

Instantly share code, notes, and snippets.

@mastbaum
Created January 21, 2012 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastbaum/1650509 to your computer and use it in GitHub Desktop.
Save mastbaum/1650509 to your computer and use it in GitHub Desktop.
A simple example of a pointer to a static member function
#include <iostream>
/* A simple example of a pointer to a static member function */
class Foo {
public:
static int threadMe(int a) {
std::cout << "Foo::threadMe: a = " << a << std::endl;
}
};
int main(int argc, char* argv[]) {
// create pointer to static member
int (*pStaticMemberFunction)(int);
// assign it
pStaticMemberFunction = &(Foo::threadMe);
// call it
(*pStaticMemberFunction)(42);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment