#include "stdafx.h"
#include <cstring>
#include <iostream>
void OutOfMenory(){
std::cerr << "unable to satisfy request for memory /n" << std::endl;
std::abort();
}
int _tmain(int argc, _TCHAR* argv[])
{
std::set_new_handler(OutOfMenory);
for (size_t i = 0; i < 10000; i++)
{
std::cout << i << std::endl;
int *p_big_data_array = new int[10000000];
}
return 0;
}
条款49 了解new-handler的行为
最新推荐文章于 2022-07-23 17:53:54 发布