#include <iostream>
#include <string.h>
#include <windows.h>
//利用重载编写求整数绝对值和求实数绝对值的两个函数
using namespace std;
class jued
{
public:
int jued1(int x)
{
if (x < 0)
x = x*(-1);
cout << "整型" << endl;
return x;
}
double jued1(double x)
{
if (x < 0)
x = x*(-1);
cout << "实型" << endl;
return x;
}
};
void main()
{
jued a;
cout<<a.jued1(100)<<endl;
cout<<a.jued1(-100)<<endl;
cout<<a.jued1(100.9)<<endl;
cout<<a.jued1(-100.9)<<endl;
system("pause");
}
#include <string.h>
#include <windows.h>
//利用重载编写求整数绝对值和求实数绝对值的两个函数
using namespace std;
class jued
{
public:
int jued1(int x)
{
if (x < 0)
x = x*(-1);
cout << "整型" << endl;
return x;
}
double jued1(double x)
{
if (x < 0)
x = x*(-1);
cout << "实型" << endl;
return x;
}
};
void main()
{
jued a;
cout<<a.jued1(100)<<endl;
cout<<a.jued1(-100)<<endl;
cout<<a.jued1(100.9)<<endl;
cout<<a.jued1(-100.9)<<endl;
system("pause");
}