我尝试在MFace
BOOST 的帮助下序列化一个类,
// class of the face
class MFace
{
public:
//constructor
MFace();
private:
//! Vector of the face nodes
mymath::Vector<DG::MNode*> Nodes;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version){
//! Vector of the face nodes
ar & Nodes;
}
};
但该类包含另一个类
mymath::Vector<MNode*> Nodes;
所以,当我尝试写入Nodes
存档时
//create a face
MFace Face;
//archive output file
std::ofstream ofs("output.txt");
boost::archive::text_oarchive ar(ofs);
// Write data to archive
ar & Face;
...
编译器给了我一个错误
error: ‘class mymath::Vector<DG::MNode*>’ has no member named ‘serialize’
我应该向 MFace 使用的每个类(特别是 mymath::Vector 和 MNodes)添加另一个“序列化”并描述它应该做什么,还是有可能在 MFace 中解决它而不接触其他类?
包括的是
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
//contains mymath::Vector<>
#include "mymath/vector.h"
//containes MNodes
#include "MNode.h"
#include <fstream>