I am fairly new to c++ but taking a course in it at uni which is adapted to unix systems but using code::blocks to practise from home. The recommended compiler command in the unix systems is:
g++ -g -std=c++98 -pedantic -Wall -Wextra lab1.cc
.
Trying to compile a basic function example I get errors when using c::b. Code below:
1 2 3 4 5 6 7 8 9 10 11
double divide(double a, double b)
{
if (std::fabs(b) < 1.0 &&
std::fabs(a) > std::numeric_limits<double>::max()*std::fabs(b))
throw std::overflow_error("arithmetic_error");
double result = a / b;
if (a != 0 && result == 0.0)
throw std::underflow_error("arithmetic_error");
return result;
}
Compiling results in the following errors:
error: 'fabs' is not a member of 'std'
error: 'overflow_error' is not a member of 'std'
error: 'underflow_error' is not a member of 'std'
If code::blocks uses a newer standard or such, can I adjust compiler to simulate the recommended course settings? I want to be able to practise in the standard I am supposed to use at the exam. Please help me!