vc6.0下 为什么捕捉不到这个异常
#include<iostream>
#include<exception>
using namespace std;
int main()
{
try {
int* p = new int[1000000000];
p[1000000]=1000;
cout<<p[1000000]<<endl;
}
catch(bad_alloc)
{
cout<<"Bad Allocation..\n"<<endl;
}
cout<<"end of program\n"<<endl;
}
[解决办法]
你在算分配了多大啊?
才1G都不到啊,根本就不存在异常啊。
[解决办法]
编译选项了自己找找,有没有启用异常
[解决办法]
我只能建议你换一个新点的编译器。
因为大家不想在VC6的各种bug什么的上面浪费精力。
[解决办法]
那就是运行成功了,有什么不理解