//错误
1
error C2084: 函数“double abs(double) throw()”已有主体
c:\users\star.lz\documents\visual studio //2013\projects\consoleapplication28\consoleapplication28\源.cpp
8
1
ConsoleApplication28
//错误
2
error C2264: “abs”: 函数定义或声明中有错误;未调用函数
c:\users\star.lz\documents\visual studio //2013\projects\consoleapplication28\consoleapplication28\源.cpp
13
1
ConsoleApplication28
#include<iostream>
using namespace std;
int abs(int x)
{
return x > 0 ? x : (-x);
}
double abs(double x)
{
return x > 0 ? x : (-x);
}
void main()
{
cout << abs(-1.234) << endl;
cout << abs(-2);
}