Re: [cpp] boost serialize 和 ostream 问题
xxmplus
xxmplus at gmail.com
Mon May 15 17:25:56 CST 2006
因为序列化和输入输出不是一回事啊
在 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
>
>
More information about the Cpp
mailing list