1 #include <iostream>
2 using namespace std;
3
4 class A
5 {
6 public:
7 static void staticmember(){cout<<"static"<<endl;}
8 void nonstatic(){cout<<"nonstatic"<<endl;}
9 virtual void virtualmember(){cout<<"virtual"<<endl;}
10 };
11
12 int main()
13 {
14 A a;
15 void (*ptrstatic)() = &A::staticmember;
16 void (A::*ptrnonstatic)() = &A::nonstatic;
17 void (A::*ptrvirtual)() = &A::virtualmember;
18
19 ptrstatic();
20 (a.*ptrnonstatic)();
21 (a.*ptrvirtual)();
22
23 system("pause");
24 return 0;
25 }