Equivalent to serialization in Java

I was wondering if there was an equivalent way to serialize objects like in Java. For example, let's say I want to store a lot of different types of objects in a file which I can later read when I restart the program.

I know I can overload the stream operators on each object and just stream them out to file, but in Java you don't even need to do this for each object, you just declare the class serializable and it takes care of copying the whole object to the stream for you. Is there a way to do this in C++ or will I have to overload all the stream operators of all the classes I want to save?
I don't think there is...I believe boost had some serialization stuff, but I don't remember for sure.
The C++ standard doesn't specify any such library, but they do exist. Check out the Boost Serialization library.
http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html

Have fun!
Topic archived. No new replies allowed.