class A { public: int i1; int i2; int f1() { return 1; } int f2() { return 2; } }; int main() { int A::*pmi = &A::i1; int (A::*pmf)(); A a; A *a2 = new A; a.*pmi = 99; int *pi = &a.i1; *pi = 98; pmf = &A::f1; return 0; }
The syntax to call f1 through pmf is (a.*pmf)().
No comments:
Post a Comment