This compile but I get strange values.... (the tellg and tellp are well pointed to zero before starts the get's)
I dont know how to write this last line (value = ) to get the right values...
So the "reinterpret" is done when the_stream.get(buffer, sizeof value); is executed ?
It is like 'magic' ????
After the_stream.get(buffer, sizeof value) is exectude,
buffer keeps being a char * , isn't ?
So I dont see the link betwen 'buffer' and 'value'. I dont know how is it possible that 'value 'can get the value 'reinterpreting the bytes'...
How does C++ it ?
You're reinterpret_castint one kind of pointer to another (which can be done just fine with a c-style cast), you're not actually reinterpret_casting the class object to a character pointer (which would not work!). Remember, pointers just point to a single memory address, they aren't actually the data itself. Think of pointers as type-safe unsigned longs.