#include 和#include 有什么区别啊
#include<iostream.h> //为什么我在这里改成<iostream>还有下面的using namespace std 写上去 就运行出现问题了
//using namespace::std;
template<typename T>
T max_value(T x,T y,T z) //函数模板的定义:求x、y、z的最大值
{ T temp;
if(x>y) temp = x;
else temp = y;
if(z>temp) temp =z;
return temp;
}
class Circle //Circle类的定义
{public:
friend ostream &operator<<( ostream &, Circle & ); //重载“<<”运算符
Circle( int a = 0, int b = 0, double c = 0.0 )
{x = a; y = b; radius = c;
}
int operator>(Circle m2) //重载“>”运算符
{if(radius>m2.radius)
return 1;
else return 0;
}
private:
int x,y; // 圆心座标
double radius; // 圆半径
}; // 类Circle定义结束
ostream &operator<<( ostream &out, Circle &C1 )
{out<<"x="<<C1.x<<" y="<<C1.y;
out<<" radius="<<C1.radius;
return out;
}
void main()
{ Circle C1(2,3,5),C2(3,5,8),C3(3,2,6); //定义3个Circle类对象
cout<<max_value(12,32,21)<<endl; //用整数作实参调用函数模板
cout<<max_value('a','A','9')<<endl; //用字符作实参调用函数模板
cout<<max_value(C1,C2,C3)<<endl; //用对象作参数调用函数模板
}