Hey all long time no ask for help :)
Just covering the 4 cast types now at the moment and just a little
confused about the reinterpret_cast type. From what i gather it
coerces the expression to be the target type, without conversion.
I understand this to be very unsafe <in my hands anyway> and just
want to understand abit more bout how it works.. ive checked it out
online and was able to figure out the other 3 casts but remain unsure
about this one.
float f = 10;
unsigned char *pFloat = reinterpret_cast<unsigned char*> (&f);
for (int j=0; j<4; ++j) {
cout << "j:" << j << pFloat[j] << endl;
}
did this just to see what output was and got
0
1
2
3A
when float was 10 and
0
1
2-
3A
when float was 30.. anyone able to explain what it is doing and why
would it be ever used in the first place?
thanks
G