Quiz · Exceptions · lesson 9 of 9
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"; }
}Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.