In this C++ tutorial, we will have a look at the modifier types in C++. A modifier is used to modify the definition of the base category so that it more specifically suits the needs of various situations.
Modifier Types in C++
There is the following C++ modifier in C++.
Signed, unsigned, long, and short modifiers can be applied to integer-base types. Signed and unsigned can also be applied to char, and long can be applied to double.
C++ allows short notation of unsigned, short, or long integers. Use the word unsigned, short, or long, without int. It implies int automatically.
For example, these two declarations declare unsigned integer variables.
unsigned a; unsigned int abc;
Important points about modifiers.
- All four modifiers can be added for type int.
- Char type allows only signed & unsigned modifiers.
- Triple form with a long suffix.
- In type allows shorthand notation.
- sing modifiers correctly can reduce memory usage.
- If we know our variable can never be negative, we should use unsigned modifiers to save memory.