C++ Boost - serialization of class containing class-hierarchy objects
Clash Royale CLAN TAG #URR8PPP C++ Boost - serialization of class containing class-hierarchy objects I have a class A , which contains the object of class B and I want to serialize it. The problem is, the class C inherits from B , so A can contain an object of either B or C . How can I efficiently implement the serialization with Boost? A B C B A B C My attempt is below, but I'm getting the error when trying to serialize A with C object, while with B it works correctly. Do you know, what am I doing wrong? A C B I've found some information about class-hierarchy objects serialization here, but it requires an explicit registration of the type in text_iarchive , whereas I need it to be registered in the A class because I'm not directly serializing B objects. text_iarchive A B #include <fstream> #include <iostream> #include <vector> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> class B friend cla...