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

Overloaded operators Given the following function... Box operator+ (const Box&b)

ID: 3806202 • Letter: O

Question

Overloaded operators

            Given the following function...

            Box operator+ (const Box&b) {

                        Box tempbox;

                        tempbox.length = this->length + b.length;

return box;
}         

            Assuming all member variables are defined, explain what this function is trying to do?

            How many objects are we dealing with here?

If I create 2 box objects and use + operator to add these 2 objects together, can I get the combined length?

What if I only have 1 box object and a int length. If I use the + operator to add these two up, can I get the combined length?

Explanation / Answer

Box operator+ (const Box&b) {
   Box tempbox;
   tempbox.length = this->length + b.length;
   return box;
}


Q.what this function is trying to do?

This function creating a new Nox object and setting the newly created box's lenth equal to sum of
calling box object and parameter boc object   

Q.How many objects are we dealing with here?

Ans: 3

Q.If I create 2 box objects and use + operator to add these 2 objects together, can I get the combined length?

Ans: yes

Q. What if I only have 1 box object and a int length. If I use the + operator to add these two up, can I get the combined length?

Ans: yes