c++classshort

Short unsigned int in C++


So in my exam in the class I was supposed to declare X as a short unsigned. I declared it short unsigned int X. Is this way still OK and correct? Thank you


Solution

  • Yes, short unsigned int and short unsigned are exactly the same type.

    Personally I prefer unsigned short for readability.

    See for yourself by testing

    std::is_same<short unsigned int, short unsigned>::value