开发者

vector and iterators

开发者 https://www.devze.com 2023-03-14 19:54 出处:网络
I have a vector that defined like below vector<Field&g开发者_运维技巧t; m_vField; I fill the vector by this command:

I have a vector that defined like below

vector<Field&g开发者_运维技巧t; m_vField;

I fill the vector by this command:

 AddFiled(const Field& aiField)
 {
   m_vField.push_back(aiField);
 }

But when I try to run iterator the vector this crashed after first iteration by "Access violation reading location"

vector<Field>::iterator it;
for(it = m_vField.begin(); it != m_vField.end() ; it++)
{
   dosomthing
}

Thanks for your help.


Think you have named the variable wrongly. Isnt the vector m_vField, whereas you have usedvField in your loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消