#include <iostream.h> #include <math.h> template <class T> class Rect { T x1,x2,y1,y2; public: Rect(T a,T b,T c,T d) { x1=a; y1=b; x2=c; y2=d; } T Area(); T Distance(); }; template <class T> T Rect<T>::Area() { return (x1-x2)*(y1-y2);} template <class T> T Rect<T>::Distance() { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } main() { Rect<int> p1(2.5,3.5,5.5,7); cout <<p1.Area()<<endl; cout <<p1.Distance()<<endl; Rect <float> p2(2.5,3.5,5.5,7.0); cout <<p2.Area()<<endl; cout <<p2.Distance()<<endl; return 0; }