Use the class rectangletype to illustrate how to overload


Use the class rectangletype to illustrate how to overload the operators +,*, ==, !=, >> and <<. First redefine the class rectangletype by declaring the instance variables as protected and then overload additional operators as defined in parts a to c a) Overload the pre- and post-increment and decrement operators to increment and decrement, respectively, the length and width of a rectangle by one unit. b) Overload the binary operator - to subtract the dimensions of one rectangle from the corresponding dimensions of another rectangle. If the resulting dimensions are not positive, output an appropriate message and no not perform the operation. c) The operators == and ! are overloaded by considering the length and widths of rectangles. Redefine the functions to overload the relational operator considering the areas of rectangles as follows : Two rectangles are the same, if they have the same area; otherwise, the rectangles are not the same. Similary, rectangle yard1 is greater the rectangle yard2 if the area of yard1 is greater than the area of yard2. Overload the remaining relational operators using similar definitions. d) Write the definition of the function to overload the operators defined in parts a to c. e) Write a test program that tests various operations on the class rectangle type.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Use the class rectangletype to illustrate how to overload
Reference No:- TGS0776861

Now Priced at $25 (50% Discount)

Recommended (99%)

Rated (4.3/5)