Search code examples
c++cqualifiers

Is signed/unsigned part of base type or is it a qualifier


Wiki page claimed the qualifiers in C++ are const and volatile.

This answer tells unsigned, unsigned and short, etc. are also qualifiers. Though the the question did mention it is about the C, the Wiki page does not tell so either on the C side. For C the qualifiers are const, volatile, restrict and _Atomic.

And the expanding message box of the qualifier Tag of Stack Overflow says

A qualifier adds an extra "quality", such as specifying volatility or constness of a variable

"Add an extra quality", from the quotation, singed/unsigned seems meet the condition, it added the restricted extra quality to an integer so that it can hold positive number only or the negative one as well.

I'm confused a bit on this issue at the moment. For C and C++, is signed, unsigned and short, etc. counted as part of the base type or the type qualifier? And please elaborate if the rules are different in C and C++.


Solution

  • In both C and C++, signed, unsigned, short and long are type specifier. They can be combined with int, even implicitly. signed and unsigned can also be combined with char.

    In contrast, qualifiers can be applied to almost any type. (There's no int& const type, only int const&)