Question: #include using namespace std; class rect { private: int length; int width; public: void set_length(int l) { length = 0; } // Fix this void

 #include using namespace std; class rect { private: int length; int

#include using namespace std;

class rect { private: int length; int width; public: void set_length(int l) { length = 0; } // Fix this void set_width(int w) { width = w; } int get_length() { return length; } int get_width() { return 0; } // Fix this int area() { return length * width; } int perimeter() { return 0; } // Fix this void print() { // Add print code here. return; } };

You are given incomplete code for a rectangle class. As given, this code compiles but does not all functions are implemented. You are to complete the following . The set length0 method currently sets the length of the rectangle to 0. Fix this to set the length to the passed in parameter. See the warking set width for assistance The get widthO method currently returis O. Fix it to return the width of the rectangle. See the working get length0 for assistance. . The area method works correctly, but the parameter) method does not. It just returns 0. Make the perimeter) method compute and return the perimeter of the rectangle object. The print) methad currently does nothing. Using cout, make the print0 method print out the length and width of the rectangle as shown in the sample runs below. A ain function is provided for you to check the methods in the rect class. Sample runs are below. User input is in bold italics. Sample run 1: Enter length and width for rectl: 4 3 Area of rectangle 1 is:12 Perimeter of rectangle 1 is: 14 Length: 4 Width: 3 Sample run 2: Enter length and width for recti: 2 7 Area of rectangle 1 is: 14 Perimeter of rectangle 1 is: 18 Length: 2 Width: 7 YOUR ANSWER Start tour Hw more about handling STDIN and STDOUT in other langua Original Code C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!