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

define a class rectangleType that stores length and width of a rectangle. a.) Ov

ID: 3531415 • Letter: D

Question

define a class rectangleType that stores length and width of a rectangle.


a.) Overload +,-,<,>,<=,>=,==,!=operators for your class. For example the following should be possible in your main program:


rectangleType rectangle4by8(4,8);

rectangleType rectangle3By2(3,2);

rectangleType rectangle7By10(7,10)=rectangle4By8+rectangle3By2;


b.) write the definitions of the functions to overload the increment, decrement, add, and multiply operators as nonmembers (friends)


c.) add friend function that overloads << operator, to make the following code possible in main:


cout<<rectangle4By8<<endl;


d.) demonstrate how all of your functions work inside main.


Explanation / Answer

#include using namespace std; class Rectangle // Class Rectangle { public: Rectangle(float=1, float=1); // Constructor float getLength(){return length;} void setLength(float L); float getWidth(){return width;} void setWidth(float W); double perimeter(void){return (length*2 + width*2);} // Perimeter function double area(void) {return length*width);} // Area funcion private: float length; float width; }; // End of class Rectangle Rectangle::Rectangle(float L, float W) // Scope function { length=L; width=W; } double Rectangle:perimeter(float L, float W) { } double Rectangle::area(float L, float W) { } void Rectangle::setWidth(float W) { if ((W < 0.0) || (W > 20.0)) { width = 1.0; } else { width = W; } return; } void Rectangle::setLength(float L) { do cout 20.0)) else { Length = L; } return; } void Rectangle::get(float L, float W) { } int main() // main() { return 0; } // End of main() rateeeeee meeeeeeee i need pointss its urgent