When a variable is cast into a different type, the actual variable is not harmed. Here is a snippet from the program currently being examined in the tutorial:
2:void somefunc(unsigned int fptr)
3:{
4: *(float*)fptr=99.9;
5:}Try adding this statement between lines (4) and (5):
C Code
printf("%d\n", fptr);C++ Code
std::cout << fptr << std::endl;This line just prints
fptr to the screen. But the point is, that fptr is printed to the screen as an unsigned int. Even though ftpr was cast into a float* in line 4, fptr was not permanently transformed into a float*. Casting merely changes the way the compiler uses the variable at the point where the cast is made.