Function pointer to member function of class source code
This snippet submitted by selvam on 2011-11-28. It has been viewed 2234 times.
Rating of 7.6 with 5 votes
#include <iostream>
using namespace std;
class A
{
public:
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;
(a->*fp)();
}
More C and C++ source code snippets
Add a snippet!