作者tyc5116 (累人啊....)
看板C_and_CPP
标题Re: [STL ] 请问List
时间Sat Jul 11 17:03:51 2009
: 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
1F:推 LPH66:有find_if 第三个参数传一个可以用()的东西进去 07/11 17:35
3F:→ tyc5116:感谢,我先看看 07/11 19:06