Thank you so much for your help. Looks like I have a bit of studying to do. I am not totally sure how this works but it does. Here is the fixed source in case someone needs to check it out.
#include <iostream>
using namespace std;
class Point
{
public:
Point(float f_x = 1.0, float f_y = 1.0, float f_z = 1.0);
~Point();
void setXYZ(float X, float Y, float Z);
void setX(float X);
void setY(float Y);
void setZ(float Z);
// return by reference
void getXYZ(float &X, float &Y, float &Z);
float getX() const;
float getY() const;
float getZ() const;
// overloading = operator to deal with pointers
Point& operator =(Point const &p);
private:
float x, y, z;
protected:
};
// define constructor with args
Point::Point(float f_x, float f_y, float f_z)
{
cout << "We're in the constructor with arguments " << (int)this /*unique identifier*/ << endl;
x = f_x;
y = f_y;
z = f_z;
}
// define destructor
Point::~Point()
{
cout << "Destructing now!!! " << (int)this /*unique identifier*/ << endl;
}
// public function to return private value of variable x
float Point::getX() const
{
return x;
}
// public function to return private value of variable y
float Point::getY() const
{
return y;
}
// public function to return private value of variable z
float Point::getZ() const
{
return z;
}
// public function to change value of private variable x
void Point::setX(float X)
{
x = X;
}
// public function to change value of private variable y
void Point::setY(float Y)
{
y = Y;
}
// public function to change value of private variable z
void Point::setZ(float Z)
{
z = Z;
}
// public function to change value of all three private variables
void Point::setXYZ(float X, float Y, float Z)
{
/* slower
setX(X);
setY(Y);
setZ(Z);*/
// faster
x = X;
y = Y;
z = Z;
}
// public function to return values of x,y,z by reference
void Point::getXYZ(float &X, float &Y, float &Z)
{
X = getX();
Y = getY();
Z = getZ();
}
// overloading = operator
Point& Point::operator =(Point const &p)
{
setX(p.getX());
setY(p.getY());
setZ(p.getZ());
// passing back value rather than address
return *this;
}
// overloading operator << (output stream)
ostream &operator <<(ostream &stream, Point &p)
{
stream << p.getX() << " " << p.getY() << " " << p.getZ();
return stream;
}
// overloading operator >> (input