← Back to Question List
C++ Quiz #140
What new Throws When Memory Runs Out
When new cannot get the memory it was asked for, which exception does it throw, and would this handler catch it?
📄 Code
1#include <iostream>2#include <new>3#include <exception>45int main() {6 try {7 throw std::bad_alloc();8 } catch (const std::exception&) {9 std::cout << "memory problem caught\n";10 }11 return 0;12}