Hello,
I am a beginner new to classes. I am trying to write a point class that displays two points when tested. However, when I test it I get my two numbers with 5 additional numbers between them i.e (1,7) I get 1684937. Here is my code and I would appreciate any help, thank you.
Point class
// Implementation file for the Point class
#include <iostream>
#include "Point.h"
usingnamespace std;
//***********************************************************
// Initialise point x and y
//***********************************************************
Point::Point()
{
x = 0.0;
y = 0.0;
}
//***********************************************************
// Constructor accepts arguments for x and y
//***********************************************************
Point::Point(double pointx, double pointy)
{
x = pointx;
y = pointy;
}
//***********************************************************
// setPoints sets the value of points x and y
//***********************************************************
void Point::setPoints(double pointx, double pointy)
{
x = pointx;
y = pointy;
}
//***********************************************************
// getPointX gets the value of point x
//***********************************************************
double Point::getX ()
{
return x;
}
//***********************************************************
// getPointY gets the value of point y
//***********************************************************
double Point::getY()
{
return y;
}
ostream &operator<<(ostream &strm, const Point &pt)
{
strm<< pt.x << ', ' << pt.y << '\n';
return strm;
}