fork download
  1. #include <iostream>
  2.  
  3. class Library {
  4.  
  5. public:
  6. enum options {
  7. OPTION1, OPTION2, OPTION3
  8. };
  9. Library(unsigned long time, char color, options option);
  10.  
  11. private:
  12. options userOption;
  13. };
  14.  
  15. Library::Library(unsigned long time, char color, options option) {
  16. userOption = option;
  17. }
  18.  
  19.  
  20.  
  21. int OPTION1 = 123;
  22.  
  23. //Library go(1000, 8, OPTION1); // error: invalid conversion from ‘int’ to ‘Library::options’
  24. Library go(1000, 8, Library::OPTION1); // no error
  25.  
  26. int main()
  27. {
  28. printf("%d %d", OPTION1, Library::OPTION1);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5512KB
stdin
Standard input is empty
stdout
123 0