Polymorphic object serialization/creation?
Posted on 2000-03-08
Hello all. I have a question about implementing object serialization in c++.
The goal is that objects should be able to write out their type (typeid().name()) in addition to their data members. When the file is read, an object of the appropriate type is allocated and then constructed from the ifstream.
I've seen remarks about how MFC does this with CRuntimeClass and CObject, but I'd like to stay away from macros. Assuming that all classes are derived from a base CSerial class, does anyone have any suggestions about how to do this? Any information appreciated. Thanks.