fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. enum NumericType : unsigned int
  5. {
  6. None = 0,
  7.  
  8. PadWithZero = 0x01,
  9. NegativeSign = 0x02,
  10. PositiveSign = 0x04,
  11. SpacePrefix = 0x08
  12. };
  13.  
  14. inline NumericType operator |(NumericType a, NumericType b)
  15. {
  16. return static_cast<NumericType>(static_cast<int>(a) | static_cast<int>(b));
  17. }
  18.  
  19. inline NumericType operator &(NumericType a, NumericType b)
  20. {
  21. return static_cast<NumericType>(static_cast<int>(a) & static_cast<int>(b));
  22. }
  23.  
  24. inline NumericType& operator |=(NumericType& a, NumericType b)
  25. {
  26. return a = (a | b);
  27. }
  28.  
  29. inline NumericType& operator &=(NumericType& a, NumericType b)
  30. {
  31. return a = (a & b);
  32. }
  33.  
  34. int main() {
  35. // your code goes here
  36. NumericType a = PadWithZero;
  37. a |= NegativeSign;
  38. cout << static_cast<int>(a) << endl;
  39.  
  40. unsigned int b = PositiveSign;
  41. b |= SpacePrefix;
  42. cout << static_cast<int>(b) << endl;
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
3
12