For the line Point::setPoint(... it tells me that it is invalid and I set it to Point::&setPoint(.. with then stats it is a illegal operation. I'm a little lost on this one anyone mine pointing me in the right direction.
class Point
{
public:
Point(double=0.0, double=0.0);
Point &setPoint(double xPoint, double yPoint);
double distance(Point & p);
void print() const;
private:
double x;
double y;
};
Point::setPoint(double xPoint, double yPoint)
{
xPoint = x;
yPoint = y;
return *this;
}
double Point::distance(Point &p)
{
double dis;
dis = sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
return dis;
}
void Point::print() const
{
cout << "(" << x << ", " << y << ")" << endl;
}
int main()
{
Point myObject, myObject2;
myObject.setPoint(4,5).print();
myObject2.setPoint(3,4).print();
return 0;
}