Function pointer to member function of class source code

This snippet submitted by selvam on 2011-11-28. It has been viewed 11783 times.
Rating of 5.1 with 75 votes

#include <iostream>

using namespace std;

class A
void func()
cout << "Inside func of class A" << endl;

int main()
  //function pointer declaration
  void (A::*fp)(); //return type,(class::function pointer)(arguments)
  fp = &A::func;//assigning
  A *a = new A;

More C and C++ source code snippets