C++ types, pointers and references
Writing a post about types in most high level languages I’m used to wouldn’t be very interesting, but I’ve recently started learning C++ and I realized that I need to understand memory a little better to be able to write and read C++ programs effectively.
There is a collection of types that should not cause many surprises. .
Integer types
char | 1 byte |
short | 2 bytes |
int | 4 bytes |
long | 8 bytes |
long long | 16 bytes |
Floating point types
float | 14 bytes |
double | 18 bytes |
double double | 116 bytes |
*The sizes above are for GNU C compiler, but might vary for different compilers
*All numeric types can be modified with the unsigned keyword. This affects the minimum and maximum possible values that can be hold and the way arithmetic operations work on them, but not their size in bytes.