Question: #include using namespace std; class Point2D { public: Point2D(int xCoord = 0, int yCoord = 0); void Print() const; Point2D operator+(int rhs); Point2D operator+(Point2D rhs);

#include using namespace std;

class Point2D { public: Point2D(int xCoord = 0, int yCoord = 0); void Print() const; Point2D operator+(int rhs); Point2D operator+(Point2D rhs); private: int x; int y; };

Point2D::Point2D(int xCoord, int yCoord) { x = xCoord; y = yCoord; }

// No need to accommodate for overflow or negative values

/* Your code goes here */ You only edit code at here, and do not change other code please!!!

void Point2D::Print() const { cout

int main() { int xCoord1; int yCoord1; int xCoord2; int yCoord2; cin >> xCoord1; cin >> yCoord1; cin >> xCoord2; cin >> yCoord2; Point2D point1(xCoord1, yCoord1); Point2D point2(xCoord2, yCoord2); Point2D sum1 = point1 + xCoord2; Point2D sum2 = point1 + point2; cout

#include using namespace std; class Point2D { public: Point2D(int xCoord = 0,

450928.2561122.9329y7 Jump to level 1 Four integers are read from input, where the first two integers are the x and y values of point 1 and the second two integers are the x and y values of point2. Define two functions to overload the + operator. The first function overloads the + operator to add a 2D point and an integer representing the x value of the point. The second function overloads the + operator to add two 2D points. Ex: If the input is 13965 , then the output is: (13,9)+6=(19,9) (13,9)+(6,5)=(19,14) Note: The sum of a point and an integer representing the x value of the point is: - the sum of the x value of the point and the integer - the y value of the point is unchanged Note: The sum of two points is: - the sum of the x values of the points - the sum of the y values of the points 12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!