I have a project well running on VC++ 2003 .Net. But I have upgraded it to VC++ 2008 then it is compiled successfully. Now, I executed it & it crashes in the following code:
CString szDCode(_T("E007"), _T("****"));
map<CString, CString>::iterator itr;
itr = m_ECodes.find(szDCode);
if(itr != m_ECodes.end())
{
szDCode = (*itr).second;
itr = m_LineComponents.find(szDCode);
if(i开发者_运维技巧tr != m_ECodes.end()) // This line is creating Error, While I have 4-5 items in it.
szDCode = (*itr).second;
}
Here the Error being generated is: Expression: map/set iterators incompatible.
Plz help me.
Abhishek
You get an iterator from the m_LineComponents
container:
itr = m_LineComponents.find(szDCode);
You try to compare this iterator against an iterator from the m_ECodes
container:
itr != m_ECodes.end()
You can only compare two iterators from the same container. Newer versions of Visual C++ include checks in the Standard Library that help you to find this sort of error. The code was never correct.
精彩评论