#include <iostream> class Test; typedef void (Test::*Fn)(void); class Test { public: explicit Test() { m_num = 0; m_fn[0] = &Test::Oper1; m_fn[1] = &Test::Oper2; } ~Test() { } void Show(int i) { if ( i > 2 ) { (*this.*m_fn[0])(); } else { (*this.*m_fn[1])(); } } void Oper1(void) { m_num += 10; std::cout << "void Oper1(), age: " <<m_num << std::endl; } void Oper2(void) { m_num += 20; std::cout << "void Oper2(), age: " <<m_num << std::endl; } private: Fn m_fn[2]; int m_num; }; int main() { Test obj; while (1) { int i; std::cin >> i; obj.Show(i); } return 0; }