fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. typedef void (*FuncType)();
  5. typedef std::vector<FuncType> SwitchType;
  6.  
  7. void FuncOne() {
  8. std::cout << "One" << std::endl;
  9. }
  10.  
  11. void FuncTwo() {
  12. std::cout << "Two" << std::endl;
  13. }
  14.  
  15. int main() {
  16. SwitchType Switch;
  17. Switch.push_back(FuncOne);
  18. Switch.push_back(FuncTwo);
  19. Switch.push_back(FuncOne);
  20. for(const auto i: {0,1,2}) Switch[i]();
  21. return 0;
  22. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
One
Two
One