C++ Variable Declaration Keywords unsigned


A type specifier that requests the unsigned version of an integer type.

  • When used alone, int is implied, so unsigned is the same type as unsigned int.
  • The type unsigned char is different from the type char, even if char is unsigned. It can hold integers up to at least 255.
  • unsigned can also be combined with short, long, or long long. It cannot be combined with bool, wchar_t, char16_t, or char32_t.


char invert_case_table[256] = { ..., 'a', 'b', 'c', ..., 'A', 'B', 'C', ... };
char invert_case(char c) {
    unsigned char index = c;
    return invert_case_table[index];
    // note: returning invert_case_table[c] directly does the
    // wrong thing on implementations where char is a signed type