Sliced On Exit
struct Base : std::exception {
const char *what() const noexcept override { return "base"; }
};
struct Derived : Base {
const char *what() const noexcept override { return "derived"; }
};
try { throw Derived{}; } catch (Base e) { std::puts(e.what()); }
try { throw Derived{}; } catch (const Base &e) { std::puts(e.what()); }
What does this print?
Sign in to answer questions and track your progress
Sign In