Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a definition of a class Rectangle using the Point class. A rectangle is specified by two corner points (bottom left and top right).

C++

Write a definition of a class Rectangle using the Point class. A rectangle is specified by two corner points (bottom left and top right). The sides of the rectangle are parallel to the coordinate axes. The implementation of the class should be as follows:

The private data members of the class include all 4 corner points of the rectangle.

There are two constructors: one takes two points as arguments and creates a rectangle with the first point as the bottom left corner and the second as the top right corner, the other (default) constructor creates a rectangle with the corners (0,0), (1,0), (0,1), (1,1). Hint: use functions Set_X, Set_Y from the class Point to set the values of the corner points.

The print member function prints all 4 corners of the rectngle, using the member function print of the class Point.

Test the class Rectangle in main(), demonstrate that all member functions work as specified.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions