fork download
  1. #include <iostream>
  2.  
  3. enum
  4. {
  5. BUTTON_LEFT = 1 << 0,
  6. BUTTON_RIGHT= 1 << 1,
  7. BUTTON_MID = 1 << 2
  8. };
  9.  
  10. int main()
  11. {
  12. int a = 0;
  13. a |= BUTTON_LEFT;
  14. a |= BUTTON_RIGHT;
  15. a |= BUTTON_MID;
  16.  
  17. if ( a & BUTTON_RIGHT )
  18. std::cout << "The button right is pressed." << std::endl;
  19.  
  20. if ( a == BUTTON_RIGHT )
  21. std::cout << "There is only the button right." << std::endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
The button right is pressed.