Share this post

Link to post

Share on other sites

The error message says, in effect, "I can't find the Wizard::save" function. This is not surprising, given that it doesn't appear in the Wizard.cpp that you posted. :)

But anyway, the normal way to 'save' and 'load' in C++ is to overload the >> and << operators. That way, you can output the objects with the same syntax you use for primitives, and you can use any stream objects you like. (There is really no reason to restrict yourself to fstreams when you define that functionality.)

Also, there is no need to .close() the file explicitly. It will take care of itself. The .close() member function is provided for special situations.

0

Share this post

Link to post

Share on other sites

Original post by ZahlmanBut anyway, the normal way to 'save' and 'load' in C++ is to overload the >> and << operators. That way, you can output the objects with the same syntax you use for primitives, and you can use any stream objects you like. (There is really no reason to restrict yourself to fstreams when you define that functionality.)

I see no wrong with to/from Binary/Network/Text functions.wizard.toBinary(file) is more to the point than file << wizard;