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

8 Question 8 . In C++ we can write code such as the following. int a = double d/

ID: 3918433 • Letter: 8

Question

8 Question 8 . In C++ we can write code such as the following. int a = double d/ value if (a d) // value // compare int and double This question uses the classes PointDbl and PointInt defined in Question 7 We shall overload operator-- as a binary operator (not a class method). 1. Let the operands be objects u and v. 2. Then u = , if and only if (i) the r values of u and u are equal and (ii) the y values of u and v are equal. . There are four versions of operators- as follows. (return type) operator- (const PointDbl (return type) operator- (const PointInt ku, const PointInt v); (return type) operator- (const PointDbl ku, const PointInt kv); (return type) operator (const Point Int ku, const PointDbl kv); ku, const PointDbl kv): . Write the function body for each overload above of operator-- . State the return type of operator- for each case.

Explanation / Answer

bool operator==(const PointDbl &u, const PointDbl &v)

{

               if(u.x == v.x && u.y ==v.y )

                              return true;

               else

                              return false;

}

bool operator==(const PointInt &u, const PointInt &v)

{

               if(u.x == v.x && u.y ==v.y )

                              return true;

               else

                              return false;

}

bool operator==(const PointDbl &u, const PointInt &v)

{

               if(u.x == v.x && u.y ==v.y )

                              return true;

               else

                              return false;

}

bool operator==(const PointInt &u, const PointDbl &v)

{

               if(u.x == v.x && u.y ==v.y )

                              return true;

               else

                              return false;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote