当前位置: 代码迷 >> 综合 >> CArray 以 std::list 为元素的引发异常
  详细解决方案

CArray 以 std::list 为元素的引发异常

热度:51   发布时间:2024-01-05 00:12:25.0


struct _my_struct
{_my_struct(){listInt.clear();}_my_struct & operator = (_my_struct & s){listInt.clear();std::list<int>::iterator itZone;//报异常/*_Mynextiter = _Parent_proxy->_Myfirstiter;引发了异常: 读取访问权限冲突。*/itZone = s.listInt.begin();while (itZone != s.listInt.end()){unsigned long l = *itZone;listInt.push_back(l);itZone++;}return *this;}std::list<int> listInt;
};CArray<_my_struct, _my_struct &>  myArray;
_my_struct myItem;
for (int i = 0; i < 5; i++)
{myItem = _my_struct();myItem.listInt.push_back(i);myArray.Add(myItem);
}for (int i = 0; i < myArray.GetCount(); i++)
{//这个语句引发异常_my_struct myItem2 = myArray[i];
}


  相关解决方案