how to separate the serialize method from this code and encapsulate it to a another class so that we don't have to write it in every class we create.
class Test
{
private:
friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar,
const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(a);
ar & BOOST_SERIALIZATION_NVP(b);
ar & BOOST_SERIALIZATION_NVP(emp);
}
int a;
int b;
Employee *emp;
public:
Test(int a, int b,int c, int d)
{
this->a = a;
this->b = b;
emp = new Employee(c,d);
}
};
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…