The problem actually is that every time you delete an item from the list, the number of items remaining decreases. You should either delete in reverse order:
int fun2(){
INT nCount = odaList.GetCount();
for(INT i=nCount-1; i>=0; i--)
{
POSITION pos = odaList.FindIndex(i);
Aa *o1Temp = odaList.GetAt(pos);
delete o1Temp;
}
odaList.RemoveAll();
return 0;
}
or always delete the top object:
int fun2(){
INT nCount = odaList.GetCount();
for(INT i=0; i<ncount;> {
POSITION pos = odaList.FindIndex(0);
Aa *o1Temp = odaList.GetAt(pos);
delete o1Temp;
}
odaList.RemoveAll();
return 0;
}
Hope that helps.