Quiz · Exceptions · lesson 7 of 7
Quiz — an exception in a destructor
What happens when this program runs?
#include <iostream>
#include <stdexcept>
struct Logger {
~Logger() { throw std::runtime_error("flush failed"); }
};
int main() {
try { Logger log; }
catch (const std::exception&) { std::cout << "caught"; }
}