Hi,
When I try to serialize class with protected members, I get the following errors: "cannot access protected member declared in class NetElement". The idea is that I'd like to have one serialization function outside of class definition. What am I doing wrong?
best regards, mightydodol
Here is the code...
// class definition
class NetElement
{
friend class boost::serialization::access;
protected:
int nelements;
int ids;
public:
static NetElement* New(){return new NetElement;}
virtual void Delete(){delete this;}
protected:
NetElement(){};
~NetElement(){};
};
// nonintrusive serialize
template<class Archive>
void serialize(Archive & ar, NetElement& element, const unsigned int version=1)
{
ar & element.nelements & element.ids;
}
int main(void)
{...
std::ofstream os("Pipe1.txt");
boost::archive::text_oarchive oa(os);
serialize(oa,el/*ref to NetElementObj*/);
...
}