#include <iostream>
struct GeneralException {
virtual void print() { std::cout << "G"; }
};
struct SpecialException : public GeneralException {
void print() override { std::cout << "S"; }
};
void f() { throw SpecialException(); }
int main() {
try {
f();
}
catch (GeneralException e) {
e.print();
}
}
In main method, when f() is being called, it will throw SpecialException. I was confused what would throw SpecialException() do ? Will it call constructor of struct SpecialException (which is not defined).