fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A;
  5.  
  6. typedef int (A::*FPTR)();
  7.  
  8. class A {
  9. private:
  10. int a;
  11. virtual int f() {return a;}
  12. public:
  13. A(int t) {a = t;}
  14. FPTR get_private() { return &A::f; }
  15. };
  16.  
  17.  
  18.  
  19. int main() {
  20. A a(123);
  21. FPTR fp = a.get_private();
  22. int res = (a.*fp)();
  23. cout << res << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
123