我目前工作的一個模擬器和遇到的調試運行時出現以下錯誤:表達式:矢量不兼容的迭代器調試斷言失敗:無效的迭代器
的代碼如下:
class Network {
private:
vector<Node*> nodes;
....
void parse_config(void);
....
};
而在parse_config方法我有一個產生錯誤的序列。這是它:
if(nodes.empty()) // add the first node to the network
{
Node current(regex_d[1]); // create current(first src) node
Node *acurrent = ¤t;
Node next_hop(regex_d[2]); // create the node we immediately send to
Node *anext_hop = &next_hop;
acurrent->add_next_hop(anext_hop);
acurrent->add_n_vchannels(regex_d[5]);
nodes.push_back(acurrent); // <== error
nodes.push_back(anext_hop); // <== here as well
}
有沒有解決方法呢? 任何幫助/建議/參考將非常感激。
塞比
您在'push_back'本身或您嘗試使用這些指針期間出現錯誤? – Naveen 2012-03-22 17:31:35