I'm new to c++ and I am only a beginner programmer with experience in C, Javascript, TI-BASIC and C++ so please forgive my newbishness.
I was wondering, how come there are different data-types that represent the same values? In the book I'm working through it explains the data types as follows:
INT = 4 bytes
Short Int = 2 bytes
Long Int = 4 bytes
Char = 1 byte
boole = 1 byte
float = 4 bytes
double float = 8 bytes
Long long int = 8 bytes
So like with INT and Long int. They take up exactly the same amount of space and they are both integers. How come they need two different categories?
The number of bytes used in the object representation of, say, int is implementation-defined. All that C++ requires is that long int can't be narrower than int, and can't be wider than long long int etc.
It depends on the platform's implementation of the data type. The standard dictates that sizeof(longint)>=sizeof(int), therefor it is perfectly possible for them to have the same size. On some platforms, however, you could also have longint be longer than int