proto/coor.hh
changeset 27 faeea3e21e82
parent 26 5685602aeb9c
child 28 3da59a3bc92e
equal deleted inserted replaced
26:5685602aeb9c 27:faeea3e21e82
     1 #ifndef COOR_H
       
     2 #define COOR_H
       
     3 
       
     4 //#define TYPE double
       
     5 
       
     6 template <typename TYPE>
       
     7 class coor {
       
     8 public:
       
     9 	TYPE x;
       
    10 	TYPE y;
       
    11 	coor() {
       
    12 		x = 0; y = 0;
       
    13 	}
       
    14 	coor(TYPE X, TYPE Y) {
       
    15 		x = X;
       
    16 		y = Y;
       
    17 	}
       
    18 	coor(const coor& c) {
       
    19 		x = c.x;
       
    20 		y = c.y;
       
    21 	}
       
    22 	void operator = (const coor& c) {
       
    23 		x = c.x;
       
    24 		y = c.y;
       
    25 	}
       
    26 	coor operator + (const coor& c) {
       
    27 		return coor(x+c.x, y+c.y);
       
    28 	}
       
    29 	coor operator - (const coor& c) {
       
    30 		return coor(x-c.x, y-c.y);
       
    31 	}
       
    32 	void operator += (const coor& c) {
       
    33 		x += c.x;
       
    34 		y += c.y;
       
    35 	}
       
    36 
       
    37 	coor operator * (const double d) {
       
    38 		return coor(x*d, y*d);
       
    39 	}
       
    40 
       
    41 };
       
    42 
       
    43 template<typename T>
       
    44 bool operator== (const coor<T>& c1, const coor<T>& c2) {
       
    45 	return ((c1.x == c2.x) && (c1.y == c2.y));
       
    46 }
       
    47 
       
    48 #endif