#include<iostream>
using namespace std;
class Fraction
{
public:
double x,y;
Fraction(double a,double b)
{
x=a;
if(b==0)
{
cout<<"The denominator is 0."<<" "<<"Enter a new value: ";
cin>>y;
}
else
y=b;
}
~Fraction(){cout<<"End"<<endl;}
friend int operator >(Fraction m,Fraction n);
friend int operator <(Fraction m,Fraction n);
};
int operator >(Fraction m,Fraction n)
{
if((m.x/m.y)>(n.x/n.y))
return 1;
else
return 0;
}
int operator <(Fraction m,Fraction n)
{
if((m.x/m.y)<(n.x/n.y))
return 1;
else
return 0;
}
int main()
{
Fraction a(2.5,6.1),b(3.33,0);
cout<<(a>b)<<endl;
cout<<(a<b)<<endl;
return 0;
}
编译后指错:cout<<(a>b)<<endl;cout<<(a<b)<<endl;???? |