I have seen this question in a C++ test and I have no idea what the solution should be. So in the code below, what is absValue?
#include <iostream>
struct absValue
{
float operator()(float f) {
return f > 0 ? f : -f;
}
};
int main( )
{
using namespace std;
float f = -123.45; absValue aObj;
float abs_f = aObj(f);
cout << "f = " << f << " abs_f = " << abs_f << endl;
return 0;
}