Re: [STL ] 請問List
: 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
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
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章