The types are defined as a set of values in C++.
They can have different proposes in a program, and that is why they are classified in this order:
- Character types: They can represent a single character, such as ‘A’ or ‘$’. The most basic type is char, which is a one-byte character.
- Numerical integer types: They can store a whole number value, such as 7 or 1024. They exist in a variety of sizes, and can either be signed or unsigned, depending on whether they support negative values or not.
- Floating-point types: They can represent real values, such as 3.14 or 0.01, with different levels of precision, depending on which of the three floating-point types is used.
- Boolean type: The Boolean type, known in C++ as bool, can only represent one of two states, true or false.
Category | Type | Contents |
Integral | char | Type char is an integral type that usually contains members of the execution character set — in Microsoft C++, this is ASCII. |
The C++ compiler treats variables of type char, signed char, and unsigned char as having different types. Variables of type char are promoted to int as if they are type signed charby default, unless the /J compilation option is used. In this case they are treated as typeunsigned char and are promoted to int without sign extension. | ||
bool | Type bool is an integral type that can have one of the two values true or false. Its size is unspecified. | |
short | Type short int (or simply short) is an integral type that is larger than or equal to the size of type char, and shorter than or equal to the size of type int. | |
Objects of type short can be declared as signed short or unsigned short. Signed short is a synonym for short. | ||
int | Type int is an integral type that is larger than or equal to the size of type short int, and shorter than or equal to the size of type long. | |
Objects of type int can be declared as signed int or unsigned int. Signed int is a synonym for int. | ||
__intn | Sized integer, where n is the size, in bits, of the integer variable. The value of n can be 8, 16, 32, or 64. (__intn is a Microsoft-specific keyword.) | |
long | Type long (or long int) is an integral type that is larger than or equal to the size of typeint. | |
Objects of type long can be declared as signed long or unsigned long. Signed long is a synonym for long. | ||
longlong | Larger than an unsigned long. | |
Objects of type long long can be declared as signed long long or unsigned long long.Signed long long is a synonym for long long. | ||
Floating | float | Type float is the smallest floating type. |
double | Type double is a floating type that is larger than or equal to type float, but shorter than or equal to the size of type long double. | |
long double 1 | Type long double is a floating type that is equal to type double. | |
Wide-character | __wchar_t | A variable of __wchar_t designates a wide-character or multibyte character type. By default,wchar_t is a native type but you can use /Zc:wchar_t- to make wchar_t a typedef forunsigned short.
Use the L prefix before a character or string constant to designate the wide-character-type constant. |
Fundamental Types has also need a amount of storage required and depending on the category it will define how much space it needs.
Group | Type names* | Notes on size / precision |
Character types | char | Exactly one byte in size. At least 8 bits. |
char16_t | Not smaller than char. At least 16 bits. | |
char32_t | Not smaller than char16_t. At least 32 bits. | |
wchar_t | Can represent the largest supported character set. | |
Integer types (signed) | signed char | Same size as char. At least 8 bits. |
signed short int | Not smaller than char. At least 16 bits. | |
signed int | Not smaller than short. At least 16 bits. | |
signed long int | Not smaller than int. At least 32 bits. | |
signed long long int | Not smaller than long. At least 64 bits. | |
Integer types (unsigned) | unsigned char | (same size as their signed counterparts) |
unsigned short int | ||
unsigned int | ||
unsigned long int | ||
unsigned long long int | ||
Floating-point types | float | |
double | Precision not less than float | |
long double | Precision not less than double | |
Boolean type | bool | |
Void type | void | no storage |
Null pointer | decltype(nullptr) |
This pages really help me out!
http://www.cplusplus.com/doc/tutorial/variables/
https://msdn.microsoft.com/en-us/library/cc953fe1.aspx
-The Admin!
Basic Types and their use in C++ by esaupreciado is licensed under a Creative Commons Attribution 4.0 International License.