Question OOP-EXC-0016
HardWhat is the output of this code?
#include <iostream>
using namespace std;
struct Base {};
struct Derived : Base {};
int main() {
try {
throw Derived();
} catch (Base&) {
cout << "base";
} catch (Derived&) {
cout << "derived";
}
return 0;
}
- A.
derived
- B.
base
- C.
Terminate
- D.
base derived
Sign up free to see the answer and a step-by-step explanation.