typedef struct _device_callstation_info
{int nGuid;/*设备名字*/char szName[JH_DEVICE_NAME_LEN+1];std::deque<STRUCT_DEVICE_CALLSTATION_ZONE> * pDequeZone;_jinhong_device_callstation_info(){nGuid = 0;memset( szName, 0, sizeof(szName) );pDequeZone = new std::deque<STRUCT_DEVICE_CALLSTATION_ZONE>;}_device_callstation_info & operator = ( _device_callstation_info & s ){nGuid = s.nGuid;memset( szName, 0, sizeof(szName) );strcpy( szName, s.szName );pDequeZone->clear();std::deque<STRUCT_DEVICE_CALLSTATION_ZONE>::iterator itZone;for ( itZone = s.pDequeZone->begin(); itZone != s.pDequeZone->end(); itZone++ ){pDequeZone->push_back( *itZone );/*在此处Debug, Release 下不一样*/}return *this;}~_device_callstation_info(){nGuid = 0;memset( szName, 0, sizeof(szName) );if ( pDequeZone && !pDequeZone->empty() ){pDequeZone->clear();delete pDequeZone;}}}STRUCT_DEVICE_CALLSTATION;
然后声明CArray<STRUCT_DEVICE_CALLSTATION,STRUCT_DEVICE_CALLSTATION&> arrCallstation;
STRUCT_DEVICE_CALLSTATION newCallstation;
. 设置值
arrCallstation.Add( newCallstation);
然后重开一个线程取值,也就是在newCallstation销毁后取值。
STRUCT_DEVICE_CALLSTATION newCallstation;
newCallstation = arrCallstation[0];
就在代码标识的地方(Release版本下)出现错误。
如上,声明为指针方式 ,在Debug与Release 下均正常。
std::deque<STRUCT_DEVICE_CALLSTATION_ZONE> * pDequeZone;
如果声明为一般变量,则在Debug下正常,而在Release下不正常。
std::deque<STRUCT_DEVICE_CALLSTATION_ZONE> dequeZone;
在代码的中的不正常的位置已经标识。*itZone,访问操作非法。难道在