Function pointer to member function of class source code

This snippet submitted by selvam on 2011-11-28. It has been viewed 6824 times.
Rating of 4.0 with 39 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

Add a snippet!