代码示例及讲解
#include <cstddef>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/string.hpp>//本例中需要对string进行存储,所以引入string.hpp;此外还有一些预定义的模板,如vector、list、map等
#include <boost/serialization/access.hpp>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Cat{
public:
Cat() {}//每个对象都必须提供一个默认构造函数
Cat(string name) { this->name = name; }
void print() { cout<<"my name is "<<this->name<<endl; }
string getName() { return this->name; }
void setName(string name) { this->name = name; }
private:
friend class b