fork download
  1. #include <iostream>
  2.  
  3. struct S {
  4. int f() { return 2; }
  5. int g() { return 3; }
  6. };
  7.  
  8. int main() {
  9. int (S::*pmf)(){&S::f};
  10.  
  11. S s;
  12.  
  13. int a = 0;
  14. a += (s.*pmf)();
  15. pmf = &S::g;
  16. a += (s.*pmf)();
  17.  
  18. std::cout << a << '\n';
  19. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
5