------------------------------------------------------------------------------
MC logo
Point Class User File
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Point Hdr File] [Point Impl File] [Point User File] [Point Class Hdr File] [Point Class Impl File] [Point Class User File] [C++ Integer Stack ADT] [C++ Integer Stack Implementation] [C++ Integer Stack Driver]
point4u.cc
#include "point4.h"
#include <iostream>

using namespace std;

main() 
{
        // Some points.
        Point a(5.2, -4.8);
        Point b(3.0, 9.0);
        Point c(-3.38);
        Point d;

        // Some arith. on the points.
        d = b.sub(c);
        cout << b << " - " << c << " = " << d << endl;
        cout << a << " + " << b << " = " << a.add(b) << endl;
        cout << a << " is " << a.dist(d) << " from " << d << endl;

        // Point variables are not references.
        Point fred[5];
        for(int m = 0; m < 5; m++) fred[m] = a;
        double w = 4.5;
        double x = -2.31;
        for(int m = 0; m < 5; m++) {
                fred[m].move(w, x);
                w += 3.4;
                x -= 1.3;
        }
        for(int m = 0; m < 5; m++) cout << fred[m] << endl;
}