Unexpected Behaviors in the following Program. Why?
Here is a program I created yesterday in my school. https://code.sololearn.com/cqfe6f4AzLw0/#cpp I don't understand some of the things, why do they happen like this. They are: 0) See the WriteToFile function. There I have simply done this to write the data to the binary file: fout.write((char*)&arr[i],sizeof(arr[i])); What I see this as is that this is an explicit conversion of a class Memory to char*. How is that possible? Did I just converted the memory to Bytes using this? Also, Putting the brackets in the functional form doesn't work here. Why? 1) In my ReadFromFile Function, the cursor in the file never reaches eof(). I created another test program to read all Entries contained and found that in the end, tellg() was returning -1, and the Data there was exactly the same as the last entry. Is is possible for the cursor to be at -1?