Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(b) (7 points) Here\'s a declaration for a circle class, which is defined by the

ID: 3819044 • Letter: #

Question

(b) (7 points) Here's a declaration for a circle class, which is defined by the radius r and the center (xy). Consider the class is completely defined (even if it is not shown). Write code to overload the and operators for the Circle class as class members (not friend functions) so that an int value can be added and subtracted, respectively, from the radius r. You do not need to add a circle to an int (see below for example cases. The center of the circle will not be affected. However, make sure the value of r is always valid after these operations our job to figure out: what values of r is invalid for a circle?) class Circle t private: int r int x, y; public: Two constructors int yy, int rr tx xx; y yy; r rr; Circle int xx Overload the and operators 7/ (Turn page to see example usage of and operators)

Explanation / Answer

The operator overloading is done using operator keyword followed with the sign.this metjodbreturns the object Circle.

Circle operator+(int rr){

                                Circle c;

                                c.x=this->x;

                                c.y=this->y;

                                c.r=r+rr;

                                return c;

                }

                Circle operator-(int rr){

                                Circle c;

                                c.x=this->x;

                                c.y=this->y;

                                c.r=r- rr;

                                return c;

                }