In the following program, where is pt1 getting it's values (1, 0)? I get pt3's values (5, 10) because I can see them in the code.
#include <iostream>
using namespace std;
class Point
{
private:
int x, y;
public:
Point() {}
Point(int new_x, int new_y) { set(new_x, new_y); }
void set(int new_x, int new_y);
int get_x();
int get_y();
};
int main()
{
Point pt1, pt2;
Point pt3(5, 10);
cout << "The value of pt1 is ";
cout << pt1.get_x() << ", ";
cout << pt1.get_y() << endl;
cout << "The value of pt3 is ";
cout << pt3.get_x() << ", ";
cout << pt3.get_y() << endl;
return 0;
}
void Point::set(int new_x, int new_y)
{
if(new_x < 0)
new_x *= -1;
if(new_y < 0)
new_y *= -1;
x = new_x;
y = new_y;
}
int Point::get_x()
{
return x;
}
int Point::get_y()
{
return y;
}