(this->*p)();的理解

来源:互联网 发布:淘宝标题带特价 编辑:程序博客网 时间:2024/05/22 04:40

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

#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;}




0 0