Question
Define the class Rectangle. class must have the following private data members and functions. Implement the functions. Length( double) Width (double) A default constructor that
Define the class Rectangle. class must have the following private data members and functions. Implement the functions.
Length( double)
Width (double)
A default constructor that sets length and width to 1.
A constructor with parameter to initialize length and width.
The set and get functions for both private data members length and width.
A void print function that display the values of the length and width.
A function that returns the area of Rectangle.
Write a main function to test the Rectangle class. In the main function you must create two Rectangle objects using each of the constructors. Then call the function print on both Rectangle objects and display the area of both objects. Copy and past all code, one statement per line.
Next,
Write a function that receives a Rectangle object as a reference parameter. Then prompts user to enter new values for the length and width and uses the set function of the object to change the length and width to new values. Test this function, in the main function ( you have already written), call this new function, pass one of the Rectangle objects as a parameter, after the call display the new values of length and width by calling the print function in the object.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started