I have a throw domain_error("Student has done no homework") exception in my grade function, if the user does not enter homework grades, causing the vector to be size of 0. then I called this function in the main, within a try and catch block, and the compiler is giving the warning.
Partial view of the main function
read_hw(cin,homework);
try
{
double _final_grade = grade(midterm,_final,homework);
streamsize prec = cout.precision();
cout << "Your final grade is "<<setprecision(3) << _final_grade <<
setprecision(prec) << endl;
}
catch(domain_error)
{
cout << "You must enter your grades. Please try again" <<endl;
return -1;
}
Exceptions should be caught by constant reference, not by value.
Use
catch(const domain_error &)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With