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

Green lines are requirements. Solve this problem in C++. Thank you! Rectangle r1

ID: 3815034 • Letter: G

Question

Green lines are requirements. Solve this problem in C++. Thank you!

Rectangle r1(10, 5)://In the appropriate file and location://Write the function to overload the stream insertion operator that will print out a rectangle'- s dimensions.//Note that rectangle rl has already been declared and initialized for you above.//The output should appear EXACTLY like this://Rectangle dimensions://Length: 10//Width: 5//Once you have written the code to implement the overloaded insertion operator, uncomment the line of code below that calls it. *********************************************************************************************************//cout

Explanation / Answer

Hi. You can add this function in your class:

friend ostream &operator<<( ostream &output, const Rectangle &rec) {

output << "Length: " << rec.lenght << endl;
output << "Width: " << rec.width << endl;
return output;
}

Please let me know in case of any issue