C++ Programming: Language Default Data Types
Jump to navigation
Jump to search
Data types[edit | edit source]
Type | Size in Bits | Comments | Alternate Names |
---|---|---|---|
Primitive Types | |||
char | ≥ 8 |
|
— |
signed char | same as char |
|
— |
unsigned char | same as char |
|
— |
short | ≥ 16, ≥ size of char |
|
short int, signed short, signed short int |
unsigned short | same as short |
|
unsigned short int |
int | ≥ 16, ≥ size of short |
|
signed, signed int |
unsigned int | same as int |
|
unsigned |
long | ≥ 32, ≥ size of int |
|
long int, signed long, signed long int |
unsigned long | same as long |
|
unsigned long int |
bool | ≥ size of char, ≤ size of long |
|
— |
wchar_t | ≥ size of char, ≤ size of long |
|
— |
float | ≥ size of char |
|
— |
double | ≥ size of float |
|
— |
long double | ≥ size of double |
|
— |
User Defined Types | |||
struct or class | ≥ sum of size of each member |
|
— |
union | ≥ size of the largest member |
|
— |
enum | ≥ size of char |
|
— |
typedef | same as the type being given a name |
|
— |
template | ≥ size of char | — | — |
Derived Types[4] | |||
type& (reference) |
≥ size of char |
|
— |
type* (pointer) |
≥ size of char |
|
— |
type [integer] (array) |
≥ integer × size of type |
|
— |
type (comma-delimited list of types/declarations) (function) |
— |
|
— |
type aggregate_type::* (member pointer) |
≥ size of char |
|
— |
[1] -128 can be stored in two's-complement machines (i.e. almost all machines in existence). In other memory models (e.g. 1's complement) a smaller range is possible, e.g. -127 ←→ +127. | ||
[2] -32768 can be stored in two's-complement machines (i.e. most machines in existence). | ||
[3] -2147483648 can be stored in two's-complement machines (i.e. most machines in existence). | ||
[4] The precedences in a declaration are: | [], () (left associative) | — Highest |
&, *, ::* (right associative) | — Lowest |