vector and iterators
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.
精彩评论