For example:
int* x = new int;
int y = reinterpret_cast<int>(x);
y
now holds the integer value of the memory address of variable x
.
Variable y
is of size int
. Will that int
size always be large enough to store the converted memory address of ANY TYPE being converted to int
?
EDIT:
Or is safer to use long int
to avoid a possible loss of data?
EDIT 2: Sorry people, to make this question more understandable the thing I want to find out here is the size of returned HEX value as a number, not size of int nor size of pointer to int but plain hex value. I need to get that value in in human-readable notation. That's why I'm using reinterpret_cast
to convert that memory HEX value to DEC value. But to store the value safely I also need to fing out into what kind of variable to it: int, long - what type is big enough?