I'm having a problem compiling this simple code in VS2017, but the code is working fine in Code Blocks. In VS2017 I've got this error message:
C2382 'abs':redefinition; different exception specifications
Here is the code below:
#include <iostream>
using namespace std;
int abs(int i);
float abs(float f);
int main()
{
cout << abs(-10) << endl;
cout << abs(-11.0f) << endl;
return 0;
}
int abs(int i)
{
cout << "Using integer abs()\n";
return i<0 ? -i : i;
}
float abs(float f)
{
cout << "Using float abs()\n";
return f<0.0f ? -f : f;
}