I used this turoial http://www.functionx.com/cpp/articles/serialization.htm to learn binary serialization, but it does not seem to be working! Creating files is no problem, but when reading them, the data is not the same as the one you put in!
Here is my code: (I am getting the same result when using this code as when compiling and running the code in the example. This code is more clean)
ofs.write((char *) & obj, sizeof (obj));
That line is directly writing to the file what is in the memory occupied by the object.
It won't be portable and it will cause trouble to virtual tables or dynamically allocated members.
NEVER do that
For serialization in C++ check the boost libraries ( as I already suggested here http://www.cplusplus.com/forum/beginner/25721/#msg136731 )
BTW you are not returning anything from readBadgerFromFile