[問題] 關於operator

看板C_and_CPP (C/C++)作者 (累人啊....)時間16年前 (2009/09/14 16:30), 編輯推噓4(405)
留言9則, 4人參與, 最新討論串1/8 (看更多)
請問一下,我建了一個list中又有list的資料結構 大概像這樣子 class TPInGra{ typedef vector<_Point> Pos; public: void SetMidPoint(_Point P); Pos& GetMidPoint(); bool GetMidPointIsEmpty(); private: int TPID; int TransitionID; Pos MidPoint; int ArcType; }; class TruTPInGra{ typedef list<TPInGra> Contents; public: void addConData(TPInGra new_Row); private: Contents Load; }; 然後我現在要用串流將產生的物件存入檔案(及讀取) 那麼對於MidPoint的這個型態要紀錄的話,那麼operator要寫在哪個地方呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.18.48.28

09/14 17:13, , 1F
Boost::serializtion
09/14 17:13, 1F

09/14 17:14, , 2F
少打一個a XD 是boost::serialization
09/14 17:14, 2F

09/14 17:14, , 3F
官方的tutorial很好懂 使用也很簡單
09/14 17:14, 3F

09/14 17:16, , 4F
用法就直接把物件丟進archieve就好.. ar & obj;
09/14 17:16, 4F

09/14 17:18, , 5F
那個好像又要再另外安裝,是嗎?
09/14 17:18, 5F

09/14 20:10, , 6F
對 serialization是boost中少數需要link library的..
09/14 20:10, 6F

09/14 20:32, , 7F
那...我研究看看好了,另外,一般的寫法有誰知道嗎?
09/14 20:32, 7F

09/14 20:44, , 8F
如果你說的是operator>>與<<,應該是寫在全域空間
09/14 20:44, 8F

09/15 07:34, , 9F
全域沒錯 因為 >> 和 << 的左邊是 std::ostream
09/15 07:34, 9F
文章代碼(AID): #1AhVyVNt (C_and_CPP)
文章代碼(AID): #1AhVyVNt (C_and_CPP)