Quiz · Exceptions · lesson 8 of 9
Quiz — what noexcept does
What happens when this program runs?
#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"; }
}Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.