#include <type_traits>
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
class test
{
public:
test() { cout << "constructor" << endl; }
void fun1() { cout << "this is fun1 call" <<endl; }
void fun2() const { cout << "this is fun2 call"<<endl; }
static void fun3() { cout << "this is fun3 call"<<endl; }
};
int main()
{
test t;
// 函数名为 *test_func
void (test::*test_func)();
// test_func 还是指针 需要&
test_func = &test::fun1;
// 调用普通方法
(t.*test_func)();
void (test::*test_const_func)() const;
test_const_func = &test::fun2;
// 调用const方法
(t.*test_const_func)();
void (*pstatic)();
pstatic = test::fun3;
//调用static方法
pstatic();
}
参考: