fork download
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. enum Colors { YELLOW = 10, ORANGE };
  5. enum BigValue {
  6. VALUE = std::numeric_limits<long>::max()
  7. };
  8. enum RgbColors : unsigned int {
  9. RED = 0x01,
  10. GREEN = 0x02,
  11. BLUE = 0x04,
  12. // BLACK = 0xFF + 1 // error: enumerator value 256 is outside the range
  13. // of underlying type ‘unsigned char’
  14. };
  15.  
  16. int main() {
  17. std::cout << sizeof(Colors) << std::endl; // 4 - sizeof(int)
  18. std::cout << sizeof(BigValue) << std::endl; // 8 - sizeof(long)
  19. std::cout << sizeof(RgbColors) << std::endl; // 1- size(unsigned char)
  20. return 0;
  21. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
4
8
4