65,187
社区成员




#include "stdafx.h"
#include <iostream>
#include <complex>
using namespace std;
class Mycomplex:public complex<double>
{
public:
Mycomplex():complex<double>(0.0,0.0)
{}
Mycomplex(double r,double i):complex<double>(r,i)
{}
friend bool operator >(Mycomplex& c1,Mycomplex& c2)
{
return abs(c1)> abs(c2);
}
};
template<class T>
T Bigger (T& a,T& b)
{
return (a> b)?a:b;
}
int main()
{
int i1 = 10, i2 = 20, i3;
double d1 = 1.1,d2 = 2.2, d3;
Mycomplex c1(1,2),c2(3,4),c3;
i3 = Bigger(i1,i2);
cout<<i3<<endl;
d3 = Bigger(d1,d2);
cout<<d3<<endl;
c3 = Bigger(c1,c2);
cout<<c3<<endl;
return 0;
}