Re: [cpp] boost serialize 和 ostream 问题
Richard Zeng
zengyongjoy at gmail.com
Mon May 15 17:29:16 CST 2006
我知道不是一回事
我不明白的是序列化是指把对象保存到文件对吧
输入输出是指在控制台输入输出对吧
还有我要问的是如何设计一个类,然后完成序列化
只利用std c++。
用MFC 必须使所有的类继承CObject,
而且我也不知道怎么利用CObject::serialize到一个文件
在06-5-15,xxmplus <xxmplus at gmail.com> 写道:
>
> 因为序列化和输入输出不是一回事啊
>
> 在 06-5-15,Richard Zeng<zengyongjoy at gmail.com> 写道:
> >
> > 下面是Boost serialization 中的demo例子
> > 为何写了serialize 函数还写个ostream<<
> > 阿,
> > 我对ostream 不是很了解,
> > 我的印象是iostream 是在控制台里输入输出的
> >
> /////////////////////////////////////////////////////////////////////////////
> > class gps_position
> > {
> > friend std::ostream & operator<<(std::ostream &os, const
> gps_position
> > &gp);
> > friend class boost::serialization::access;
> > int degrees;
> > int minutes;
> > float seconds;
> > template<class Archive>
> > void serialize(Archive & ar, const unsigned int /* file_version */){
> > ar & degrees & minutes & seconds;
> > }
> > public:
> > // every serializable class needs a constructor
> > gps_position(){};
> > gps_position(int _d, int _m, float _s) :
> > degrees(_d), minutes(_m), seconds(_s)
> > {}
> > };
> > std::ostream & operator<<(std::ostream &os, const gps_position &gp)
> > {
> > return os << ' ' << gp.degrees << (unsigned char)186 << gp.minutes<<
> > '\'' << gp.seconds << '"';
> > }
> > _______________________________________________
> > Cpp mailing list
> > Cpp at codingnow.com
> > http://codingnow.com/mailman/listinfo/cpp
> >
> >
>
> _______________________________________________
> Cpp mailing list
> Cpp at codingnow.com
> http://codingnow.com/mailman/listinfo/cpp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20060515/ed3419a7/attachment-0001.html
More information about the Cpp
mailing list