Question: c++ LU 202018-2019%20(1) Question 5: Operator Overloading! (22 points) Assume we have a RectArea class. Each Rect Area has an array of 4 integers (x1,
LU 202018-2019%20(1) Question 5: Operator Overloading! (22 points) Assume we have a RectArea class. Each Rect Area has an array of 4 integers (x1, vl. length, width) where (x1, yl) represents the coordinates of the left upper corner, and (length and width) represent the length and width of the rectangular area. Given the following class definition: class RectArea public: RectAreaO; RectArea operator+(RectArea&rhs); Rectarea operator"(float); bool operator RectArea&rhs); vold SetValues(int_x, int_y, int_length, int_width); Dr | int x,y,length, width: Write down the implementation of the following functions: a) RectArea operator+(RectArea & rhs): the function adds two rectangular areas and return a new area object. The left upper corner of the new area will be in the middle between the left upper corners of the current and this rectangle. The length of the new area will be combining the two lengths, and so is the case for the width:(8 points) b) RectArea operator"(float weight): the function expands the length (when weight >1) and or shrinks the length (when weight =(RectArea & rhs): the function compares two RectAreas, and return true if the left one is larger or equal to the right one. Note, the area of a rectangle = length * width. (6 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
