Skip to content
Quiz · Exceptions · lesson 6 of 7

Quiz — what noexcept does

What happens when this program runs?

C++
#include <iostream>
#include <stdexcept>

void check_age(int age) noexcept {
    if (age < 0) {
        throw std::invalid_argument("negative age");
    }
}
int main() {
    try { check_age(-1); }
    catch (const std::exception&) { std::cout << "caught"; }
}