grid3d.h

Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 using namespace std;
00004 
00005 // grid3d: a class to represent a grid point (x, y, z) in 3-dimensional
00006 //         space, where x is the x co-ordinate, y is the y co-ordinate, and
00007 //         z is the z co-ordinate.
00008 //         x is represented by data[0]
00009 //         y is represented by data[1]
00010 //         z is represented by data[2]
00011 
00012 class grid3d {
00013 
00014 public:
00015    // default constructor. It creates a point (0,0,0)
00016    grid3d();
00017 
00018    // copy constructor
00019    grid3d(const grid3d&);
00020 
00021    // conversion constructor that can convert an integer to a grid3d object
00022    grid3d(int);
00023 
00024    // another constructor
00025    grid3d(int, int, int);
00026  
00027    // destructor;
00028    ~grid3d();
00029 
00030    // assignment operator
00031    grid3d & operator=(const grid3d & );
00032 
00033    // function for output. 
00034    void print() const;
00035 
00036    // Three functions to return the co-ordinates of the grid point
00037    // getx() returns the integer x co-ordinate
00038    // gety() returns the integer y co-ordinate
00039    // getz() returns the integer z co-ordinate
00040    int getx() const;
00041    int gety() const;
00042    int getz() const;
00043 
00044    // Overload the operator ">>" such that if PT is of type grid3d,
00045    // cin >> PT   asks the user for three integers: x co-ordinate,
00046    // y co-ordinate and z co-ordinate.
00047    friend istream& operator>>(istream&, grid3d&);
00048 
00049 private:
00050    int *data;
00051 } ;
00052 

Generated on Sat Sep 18 11:09:49 2010 for A Grid 3D Project by  doxygen 1.4.7