首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

这种内存有关问题最头疼了好不啦!Unhandled Exception at XXXXX in xxx.exe Access Violation

2012-08-11 
这种内存问题最头疼了好不啦!Unhandled Exception at XXXXX in xxx.exe Access Violation!C/C++ codevoid

这种内存问题最头疼了好不啦!Unhandled Exception at XXXXX in xxx.exe Access Violation!

C/C++ code
void PatientDatebase::SortPatientByLastname(){    database.sort(greater<Patient>());    list<Patient>::iterator it;    for(it = database.begin(); it != database.end(); ++it)    {        cout << '\t' << it->first_name << '\t' << it->last_name << '\t' << it->SIN << '\t' << it->doc_name << '\t' << it->ID << endl;    }}void main(string outfile){        PatientDatebase pData;    cout<<"sort patients by last name: "<<endl;    pData.SortPatientByLastname();}


错误信息
'Patient.exe': Loaded 'C:\Users\lrp\Documents\Visual Studio 2010\Projects\Patient\Debug\Patient.exe', Symbols loaded.
'Patient.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'Patient.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'Patient.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'Patient.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'Patient.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
First-chance exception at 0x0ff4ad4a (msvcp100d.dll) in Patient.exe: 0xC0000005: Access violation reading location 0x00000005.
Unhandled exception at 0x0ff4ad4a (msvcp100d.dll) in Patient.exe: 0xC0000005: Access violation reading location 0x00000005.
First-chance exception at 0x0ff4ad4a (msvcp100d.dll) in Patient.exe: 0xC0000005: Access violation reading location 0x00000005.
Unhandled exception at 0x0ff4ad4a (msvcp100d.dll) in Patient.exe: 0xC0000005: Access violation reading location 0x00000005.
First-chance exception at 0x0ff4ad4a (msvcp100d.dll) in Patient.exe: 0xC0000005: Access violation reading location 0x00000005.
Unhandled exception at 0x0ff4ad4a (msvcp100d.dll) in Patient.exe: 0xC0000005: Access violation reading location 0x00000005.

错误出处
call stack window 指示>msvcp100d.dll!std::_Container_base12::_Orphan_all() Line 201 + 0x12 bytes

在xutility中
C/C++ code
inline void _Container_base12::_Orphan_all()    {    // orphan all iterators #if _ITERATOR_DEBUG_LEVEL == 2    if (_Myproxy != 0)        {    // proxy allocated, drain it        _Lockit _Lock(_LOCK_DEBUG);        for (_Iterator_base12 **_Pnext = &_Myproxy->_Myfirstiter;            [color=#FF0000]*_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter)//在这行出错[/color]            (*_Pnext)->_Myproxy = 0;        _Myproxy->_Myfirstiter = 0;        } #endif /* _ITERATOR_DEBUG_LEVEL == 2 */    }


[解决办法]
我这边编译没问题啊,,
不过我把
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
这部分注释了。

你的代码好像有2个main函数。。
[解决办法]
在VC6下验证了你的代码,没能重现你遇到的问题。
执行的很顺利。

热点排行