Skip to content
Quiz · Exceptions · lesson 3 of 9

Quiz — catch order

What does the program print?

C++
#include <iostream>

struct Error {};
struct NotFound : public Error {};

int main() {
    try { throw NotFound{}; }
    catch (const Error&) { std::cout << "Error"; }
    catch (const NotFound&) { std::cout << "NotFound"; }
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way