Reading/writing files to/from a struct/class
问题 I'd like to read a file into a struct or class, but after some reading i've gathered that its not a good idea to do something like: int MyClass::loadFile( const char *filePath ) { ifstream file ( filePath, ios::in | ios::binary ); file.read ((char*)this, 18); file.close(); return 0; } I'm guessing if i want to write a file from a struct/class this isn't kosher either: void MyClass::writeFile( string fileName ) { ofstream file( fileName, ofstream::binary ); file.write((char*)this, 18); file