fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class foo
  7. {
  8. public:
  9. static void setEmail(string s) { cout << "setEmail: " << s << endl; }
  10. static void setPassword(string s) { cout << "setPassword: " << s << endl; }
  11. static void setName(string s) { cout << "setName:" << s << endl; }
  12. static void setAddress(string s) { cout << "setAddress:" << s << endl; }
  13. static void setPhone(string s) { cout << "setPhone:" << s << endl; }
  14. };
  15.  
  16. int main()
  17. {
  18. foo *newAC = new foo;
  19.  
  20. void (*functions[5])(string) = {
  21. foo::setEmail,
  22. foo::setPassword,
  23. foo::setName,
  24. foo::setAddress,
  25. foo::setPhone,
  26. };
  27.  
  28. for (int i = 0; i < 5; i++)
  29. functions[i]("YA");
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
setEmail: YA
setPassword: YA
setName:YA
setAddress:YA
setPhone:YA