ok i feel sorry for you now so here you go. This could be better as the operator + and operator - should be nonmembers but i followed your interface....
the .h file
Code:
class Point
{
public:
Point(double x = 0.0, double y = 0.0, double z = 0.0):
x_(x),y_(y),z_(z)
{ ++ctr_;}
Point(const Point& rhs):
x_(rhs.x_),y(rhs.y_),z(rhs.z_)
{ ++ctr_;}
~Point()
{ --ctr_;}
void X(double x) { x_ = x;}
void Y(double y) { y_ = y;}
void Z(double z) { z_ = z;}
//double& X();
const double& X() const { return x_;}
//double& Y();
const double& Y() const { return y_;}
//double& Z();
const double& Z() const {return z_;}
Point operator+(const Point& rhs)
{
return Point( x_+rhs.x_,y_+rhs.y_,z_+rhs.z_);
}
const Point& operator+=(const Point& rhs)
{
x_+= rhs.x_;
y_+= rhs.y_;
z_+= rhs.z_;
return *this;
}
Point operator-(const Point& rhs);
{ return Point( x_-rhs.x_,y_-rhs.y_,z_-rhs.z_);}
const Point& operator-=(const Point& rhs)
{
x_-= rhs.x_;
y_-= rhs.y_;
z_-= rhs.z_;
return *this;
}
static int NumPoints(){ return ctr_;}
private:
// coordinates of point in three-dimensional coordinate system
double x_, y_, z_;
static int ctr_;
};
the .cpp file
Code:
#include "assignment7.h"
int Point::ctr_ = 0;
Now read thru that. make sure you understand everything thats going on. Read your assignment again and look at the code and it should come together.