fork download
  1. #include <iostream>
  2.  
  3. class Hoge {
  4. private:
  5. int a;
  6. void f() { std::cout << "hoge:" << a << std::endl; }
  7. public:
  8. void (Hoge::*g())() { return &Hoge::f; }
  9. Hoge(int a) { this->a = a; }
  10. };
  11.  
  12. int main() {
  13. Hoge *hoge = new Hoge(300);
  14. (hoge->*(hoge->g()))();
  15. delete hoge;
  16. }
  17. /* end */
  18.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
hoge:300