The C++ programming language has a wide variety of data types. In this article, you are going to get an overview of how these data types are classified.
A data type is a computer representation of identifiers such as variables or constants. The C++ data types are divided into 3 categories.
- Builtin types
- User-defined types
- Derived-types
Modifiers
The C++ language supports all the primitive data types like C language. The range of each of the basic data types can be changed using modifiers. A modifier changes the range of allowed values for a built-in data type.
The C++ modifiers are listed below.
- signed
- unsigned
- short
- long
The list of all the builtin data types with each modifier and their range is given in the following table.
Data Type | Size | Range |
char | 1 byte | |
unsigned char | 1 byte | |
signed char | 1 byte | |
int | 2 bytes | |
unsigned int | 2 bytes | |
signed int | 2 bytes | |
short int | 2 bytes | |
long int | 4 bytes | |
signed long int | 4 bytes | |
unsigned long int | 4 bytes | |
float | 4 bytes | |
double | 8 bytes | |
long double | 10 bytes |
Note: Some of the ranges is compiler dependent.