请问引起异常: Microsoft C++ exception: int @ 0x0012fd00的原因
noono 2006-12-29 11:26:15 // exception.cpp : 定义控制台应用程序的入口点。
//
#include "windows.h"
#include "stdafx.h"
#include "string.h"
#include "time.h"
using namespace std;
class TestClass
{
public:
int SetVal();
private:
int m_val;
};
int TestClass::SetVal()
{
srand( (unsigned)time( NULL ) );
for(int i=0;i<5000;i++)
{
m_val=rand();
if(m_val<1000)
break;
else
continue;
}
if(m_val>=100)
throw m_val;
cout<<dec;
cout<<m_val<<endl;
return m_val;
}
int _tmain(int argc, _TCHAR* argv[])
{
TestClass c_Test;
try
{
c_Test.SetVal();
}
catch(int e)
{
cout<<e<<"大于上限,预设的上限值是 100 "<<endl;
cout<<"press any key to continue...";
cin.ignore();
}
return 0;
}
/*
“exception.exe”: 已加载“C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\exception\Debug\exception.exe”,已加载符号。
“exception.exe”: 已加载“C:\WINDOWS\system32\ntdll.dll”,未加载任何符号。
“exception.exe”: 已加载“C:\WINDOWS\system32\kernel32.dll”,未加载任何符号。
exception.exe 中的 0x7c812a5b 处最可能的异常: Microsoft C++ exception: int @ 0x0012fd00 。
程序“[2372] exception.exe: 本机”已退出,返回值为 0 (0x0)。
*/