fork download
  1. #include <iostream>
  2.  
  3. struct T
  4. {
  5. T(int x) : x(x) {};
  6. void foo() { std::cout << x; }
  7.  
  8. private:
  9. int x;
  10. };
  11.  
  12. int main()
  13. {
  14. typedef void (T::*P)();
  15. P fooptr = &T::foo;
  16.  
  17. T obj(5);
  18. (obj.*fooptr)(); // Output: 5
  19. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
5