C++ Program - Writing and reading classes into a file using serialization and deserialization