forward declared class serialization
hi all, I am in learning stage of the boost serialization concept. I have one small problem in my project again. Here i have to serialize a pointer of a forward declared class. i dont how to do this. Pls help me to do this. May be the solutuion is too tough, it seems to tough for me, coz i have less knowledge about the c++. I am using, Version:1.36.0 compiler: gnu-gcc-4.1.1-binutils-2.16.1/x86_64-pc-linux2.4/bin/g++ my code looks like. class fd; class base: class derived { ..... fd *ptr; ..... }; i have done it like serialization method is class fd; class base: class derived { ..... fd *ptr; ..... friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int file_version) { (void) file_version; ar & ps_core_; ar & boost::serialization::base_object<derived>(*this); } }; //end of class base Thanks in advance, Thanks for your time. Niranjan
Try:
class fd;
class base: class derived
{
.....
fd *ptr;
.....
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int file_version)
{
ar & boost::serialization::base_object<derived>(*this);
ar & ptr;
ar & ps_core_;
}
}; //end of class base
"niranjan bangera"
participants (2)
-
niranjan bangera
-
Robert Ramey