Hello,
When I compile the following code I get this single error:
In constructor `Point::Point expected `{' before ':' token ()':
I cannot figure out what is wrong. What am I missing? Thanks.
Header file
#include <iostream>
using std::cout;
using std::endl;
class Point
{
friend void setX( Point &, int );
friend void setY( Point &, int );
public:
Point()
: xCoordinate( 0 )
: yCoordinate( 0 )
{
}
void print()
{
cout << "( " << xCoordinate << "," << yCoordinate << " )" << endl;
}
private:
int xCoordinate;
int yCoordinate;
};
Main program
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include "point.h"
void setX( Point &p, int value )
{
p.xCoordinate = value;
}
void setY( Point &p, int value )
{
p.yCoordinate = value;
}
int main()
{
int xCoord, yCoord;
Point coordinatePlane;
cout << "A coordinate plane is formed by a horizontal axis and a vertical \n"
<< "axis often labeled the x-axis and y-axis, respectively. \n\n" << endl;
cout << "Enter the x-axis: ";
cin >> xCoord;
setX( coordinatePlane, xCoord );
cout << "\n\nEnter the y-axis: ";
cin >> yCoord;
setX( coordinatePlane, yCoord );
coordinatePlane.print();
return 0;
}