On 4/22/16 5:38 AM, Elizabeta wrote:
Hi I have the following code :
class MyClass { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive &ar, const unsigned int version) {} };
class MyClass2 : public MyClass {};
MyClass2* ss = new MyClass2; std::ofstream ofs("C:\\test.xml"); boost::archive::xml_oarchive oa(ofs); oa & boost::serialization::make_nvp("test",ss);
I am serializing trough the derived class pointer. The derived class doesnot have serialize function. The Base have. And I was expecting compiler to give me error that MyClass2 doesnot have serialize function. But this code compiles without errors. I am using vs2010.
the friend gives the serialization library access to your private serialization function. But I was surprised by this as well. I don't think it's wrong though. Robert Ramey