[STL ] 初始化會失敗
不好意思,結構上有點複雜,就像前幾天說的那個,類似資料庫的結構
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);
int Get_First_Ob_ID();
int Get_Last_Ob_ID();
Point Get_First_Ob_Coodinate();
Point Get_Last_Ob_Coodinate();
TP_Gra Get_Now_OB(int vID);
//仿函式
class Find_Ob_by_ID{
public:
Find_Ob_by_ID (int val):_value(val){}
bool operator()(TP_Gra& lhs){
return (lhs.Get_ID() == _value);}
private:
int _value;
};
private:
Contents Load;
};
class Token_Place_Output{
typedef vector<_Point> Pos;
public:
void Set_TP_ID(int vID);
int Get_TP_ID();
void Set_TP_Con_Trans_ID(int vID);
int Get_TP_Con_Trans_ID();
void Set_Mid_Point(_Point P);
void Set_Arc_Type(int type);
int Get_Arc_Type();
void Clear();
private:
int TP_ID;
int Transition_ID;
Pos Mid_Point;
int Arc_Type;
};
class Truckload_Con_TP_Out{
typedef list<Token_Place_Output> Contents;
public:
Truckload_Con_TP_Out();
Truckload_Con_TP_Out(Token_Place_Output one_Row);
void add_Con_Data(Token_Place_Output new_Row);
Token_Place_Output Get_Now_OB(int vTP_ID,int vTransition_ID);
Token_Place_Output Get_First_OB();
Token_Place_Output Get_End_OB();
int Get_Count();
// 仿函式
class Find_Ob_by_ID{
public:
Find_Ob_by_ID (int vTP_ID,int vTransition_ID):TP_ID(vTP_ID),
Transition_ID(vTransition_ID) {}
bool operator()(Token_Place_Output& lhs){
return (lhs.Get_TP_ID() == TP_ID) &&
(lhs.Get_TP_Con_Trans_ID()==Transition_ID);
}
private:
int TP_ID;
int Transition_ID;
};
private:
Contents Load;
};
然後我在主程式(在windows form上面)宣告了
Truckload_Con_TP_Out TPOut;
...
然後在某個事件中打了
for (list<Token_Place_Output>::iterator i=TPOut.Get_First_OB();
i=TPOut.Get_End_OB();i++){}
(這只是個測試而已)
然後會有這樣的錯誤
error C2440: '正在初始化' : 無法由 'Token_Place_Output' 轉換為
'std::list<_Ty>::_Iterator<_Secure_validation>'
error C2679: 二元運算子 '=' : 找不到使用右方運算元型別
'Token_Place_Output' 的運算子 (或是沒有可接受的轉換)
變數i的宣告出了問題,但我不知道錯在哪,麻煩有經驗的大大回答一下,謝謝
Token_Place_Output Truckload_Con_TP_Out::Get_First_OB(){
return *(Load.begin());}
(是因為這個定義才錯的嗎??)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.18.48.28
※ 編輯: tyc5116 來自: 163.18.48.28 (07/20 22:53)
※ 編輯: tyc5116 來自: 163.18.48.28 (07/20 23:10)
推
07/20 23:17, , 1F
07/20 23:17, 1F
不加的話
error C2664: 'Token_Place_Output::Token_Place_Output(const
Token_Place_Output &)' : 無法將參數 1 從
'std::list<_Ty>::_Iterator<_Secure_validation>'
轉換成 'const Token_Place_Output &'
※ 編輯: tyc5116 來自: 163.18.48.28 (07/20 23:19)
→
07/20 23:24, , 2F
07/20 23:24, 2F
→
07/20 23:52, , 3F
07/20 23:52, 3F
→
07/20 23:52, , 4F
07/20 23:52, 4F
→
07/20 23:53, , 5F
07/20 23:53, 5F
→
07/20 23:53, , 6F
07/20 23:53, 6F
→
07/20 23:54, , 7F
07/20 23:54, 7F
→
07/21 00:04, , 8F
07/21 00:04, 8F
→
07/21 00:47, , 9F
07/21 00:47, 9F
→
07/21 00:48, , 10F
07/21 00:48, 10F
→
07/21 01:03, , 11F
07/21 01:03, 11F
→
07/21 01:03, , 12F
07/21 01:03, 12F
→
07/21 01:06, , 13F
07/21 01:06, 13F
→
07/21 01:06, , 14F
07/21 01:06, 14F
→
07/21 01:11, , 15F
07/21 01:11, 15F
→
07/21 01:11, , 16F
07/21 01:11, 16F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章