fork download
  1. #include <cstdio>
  2.  
  3. class ham;
  4. typedef void (ham::*fn)();
  5.  
  6. class ham {
  7. public:
  8. fn get_fn() { return &ham::egg; }
  9. private:
  10. void egg() { puts("hello world"); }
  11. };
  12.  
  13. int main() {
  14. ham a;
  15. fn b = a.get_fn();
  16. (a.*b)();
  17. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
hello world