try { for (int i = 0; i<1000; i++) { test1 = new Test(); cout << i << " new dog success..." << endl; } } catch (bad_alloc err) { cout << "fail:"<<err.what()<< endl; }