Question: C++ programming Class PointXY The class PointXY will be used below in questions in this exam. class PointXY { public: PointXY() { x = 0;
C++ programming Class PointXY The class PointXY will be used below in questions in this exam. class PointXY { public: PointXY() { x = 0; y = 0; } void set(double a, double b) { x = a; y = b; } double getx() const { return x; } double gety() const { return y; } private: double x, y; } This question uses the class PointXY defined in Sec. 1.2 and the class Polygon defined in Question 2. Overload operator+ to add two PointXY objects PointXY operator+ (const PointXY &u, const PointXY &v); Write a function shift with the following signature. Polygon shift(const Polygon &p, const PointXY &s); If the points in p are vi , the points in the output object are vi + s. Hence if q = shift(p,s), then the polygon q is the polygon p shifted by the point s. Note: 1. You may assume the polygon p is not empty. 2. Do not waste time on validation checks to test if num <= 0 in p.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
