Re: [STL ] 請問List

看板C_and_CPP (C/C++)作者 (累人啊....)時間16年前 (2009/07/11 17:03), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串2/10 (看更多)
: class TP_Gra{ : public: : TP_Gra(int vID,Point vOrigin_Position); : TP_Gra(); : ~TP_Gra(); : : void Set_ID(int vID){ID=vID;} : int Get_ID(){return ID;} : : void Set_Coodinate(Point Position); : Point Get_Coodinate(){return Origin_Position;} : private: : int ID; : Point Origin_Position; : }; : class Truckload_TP_Gra{ : typedef list<TP_Gra> Contents; : public: : Truckload_TP_Gra(); : Truckload_TP_Gra(TP_Gra one_TP); : void add_TP(TP_Gra new_TP); : Contents::const_iterator begin(); : Contents::const_iterator end(); : : private: : Contents Load; : }; : : 推 Cloud:不清楚為什麼你要將iterator暴露出來..回傳TP_Gra比較好吧 07/10 15:55 : → Cloud:改為 Contents::iterator 應該就行了 07/10 15:56 : → Cloud:最後的元素用 list<T>::back() 07/10 15:57 謝謝回答,這個問題解決了,但是又發現了另一個問題 如果要顯示list中間的其中一筆,又該怎麼用了 好像不能用find(事實上如果可以的話我也不知道要怎麼用) 假設我現在要尋找ID為5的TP_Gra物件,我該怎麼寫呢 又如果現在的型態不是list而是vector等等的型態的話 那用find來尋找 find的參數是(範圍1,範圍2,值) 則第三個參數我該怎麼表示呢? 以上兩個問題,麻煩有經驗的大大回答,謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.162.131.54

07/11 17:35, , 1F
有find_if 第三個參數傳一個可以用()的東西進去
07/11 17:35, 1F

07/11 18:07, , 2F
07/11 18:07, 2F

07/11 19:06, , 3F
感謝,我先看看
07/11 19:06, 3F
文章代碼(AID): #1AM5Lwf9 (C_and_CPP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
1
3
以下文章回應了本文
2
7
完整討論串 (本文為第 2 之 10 篇):
0
2
0
1
2
6
1
1
2
9
2
10
2
7
2
3
1
3
文章代碼(AID): #1AM5Lwf9 (C_and_CPP)