fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct B
  5. {
  6. void (B::*pf)(int, int); // data member
  7. B () : pf(&B::foo) {}
  8. void foo (int i, int j) { cout<<"foo(int, int)\n"; } // target method
  9. };
  10.  
  11. int main ()
  12. {
  13. B obj;
  14. (obj.*obj.pf)(1, 2);
  15. }
  16.  
Success #stdin #stdout 0s 2724KB
stdin
Standard input is empty
stdout
foo(int, int)