For example if i have a class named Obj
and an Obj
named obj1
. When I want to write in a binary file with reinterpret_cast
I open that file in binary mode and then,
outstream.write( reinterpret_cast<const char *>(&obj1), sizeof(obj1) )
where outstream is a ifstream.
When i want to read from that file,
instream.read( reinterpret_cast<char *>(&obj1), sizeof(obj1) )
What happened. It read the representation of obj1
in binary and convert to obj1
or how this is working. When I write I understand that it interpret obj1
an one byte but when I read I don't understand what happens.