class neg_sum{};
int main(){
try {
. ...
.
. ...
} catch(neg_sum const & e){
. std::cout << "negative value"<<"\n";
}
}
In der Funktion
double solve_quadratic(int a, int b, int c) {
double delta = pow(b, 2) - (4 * a * c);
if (delta < 0) {
throw Negative_delta{};
}
. .....
}