fork download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. class A
  5. {
  6. public:
  7. enum Option { ViewWidth, ViewHeight, DPI, RefreshRate, VsyncMode, Multisampling };
  8. A() : a(0), b(1), c(2), d(3), e(4), f(5)
  9. {
  10. options[ViewWidth] = &a;
  11. options[ViewHeight] = &b;
  12. options[DPI] = &c;
  13. options[RefreshRate] = &d;
  14. options[VsyncMode] = &e;
  15. options[Multisampling] = &f;
  16. }
  17.  
  18. int getOption(Option op) { return *options[op]; }
  19.  
  20. private:
  21. int a, b, c, d, e, f; // many variables
  22. std::map<Option, int*> options;
  23. };
  24.  
  25. int main(int argc, char* argv[])
  26. {
  27. A a;
  28. std::cout << a.getOption(A::DPI) << std::endl;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 2988KB
stdin
Standard input is empty
stdout
2