fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class ABC
  6. {
  7. public:
  8. void f1() { cout << "#1" << endl; }
  9. void f2() { cout << "#2" << endl; }
  10. };
  11.  
  12. int main()
  13. {
  14. void (ABC::*f[])() = {&ABC::f1, &ABC::f2};
  15. ABC myClass;
  16. int x;
  17.  
  18. while(cin >> x)
  19. (myClass.*f[x&1])();
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3472KB
stdin
1
2
100
-7
16
stdout
#2
#1
#1
#2
#1