(this->*p)();이해하다

358 단어
다음 절차는 흔히 볼 수 있는 것이니 익히십시오.
#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;
}

좋은 웹페이지 즐겨찾기