fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. void(A::*fn)() = &A::do_work;
  7. void do_work() { cout << "Hello, world!"; }
  8. };
  9.  
  10. int main()
  11. {
  12. A a;
  13. (a.*(a.fn))();
  14. }
  15.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Hello, world!