下面的程序是很常见的, 来熟悉一下:

#include <iostream>
using namespace std;

class A
{
	void (A::*p)(); // 指向类的成员函数

	void print()
	{
		cout << "hello world" << endl;
	}

public:
	A()
	{
		p = &A::print;
	}

	void fun()
	{
		(this->*p)(); // 理解一下
	}
};

int main()
{
	A a;
	a.fun();
	
	return 0;
}





本文转载:CSDN博客