vector.cc
changeset 45 7197576fedcf
parent 43 cf8c1b5127b2
child 54 c064ce9f40f5
equal deleted inserted replaced
44:bb6586b1c547 45:7197576fedcf
    18 
    18 
    19       public:
    19       public:
    20         Vector (int xx = 0, int yy = 0);
    20         Vector (int xx = 0, int yy = 0);
    21        ~Vector ();
    21        ~Vector ();
    22 
    22 
    23         int X () { return x; }
    23         int X () { return x; };
    24         int Y () { return y; }
    24         int Y () { return y; };
    25 
    25 
    26         Vector operator+ (Vector&);
    26         Vector operator+ (Vector &);
    27         Vector operator- (Vector&);
    27         Vector operator- (Vector &);
    28 
    28 
    29         void vector ();
    29         void vector ();
    30         double abs ();
    30         double abs ();
    31     };
    31     };
    32 
    32 
    37 
    37 
    38     Vector::~Vector () {
    38     Vector::~Vector () {
    39         fprintf (stderr, "Removing Vector (%.3d, %.3d)\n", x, y);
    39         fprintf (stderr, "Removing Vector (%.3d, %.3d)\n", x, y);
    40     }
    40     }
    41 
    41 
    42     Vector Vector::operator+ (Vector& v) {
    42     Vector Vector::operator+ (Vector & v) {
    43         return Vector (x + v.X (), y + v.Y ());
    43         return Vector (x + v.X (), y + v.Y ());
    44     }
    44     }
    45 
    45 
    46     Vector Vector::operator- (Vector& v) {
    46     Vector Vector::operator- (Vector & v) {
    47         return Vector (x - v.X (), y - v.Y ());
    47         return Vector (x - v.X (), y - v.Y ());
    48     }
    48     }
    49 
    49 
    50     double Vector::abs () {
    50     double Vector::abs () {
    51         return sqrt (x * x + y * y);
    51         return sqrt (x * x + y * y);