Question: Write a C + + program that defines a class called Rectangle with the following requirements: The class should have two private member variables: width
Write a C program that defines a class called Rectangle with the following requirements:
The class should have two private member variables: width and height, both of type int.
It should have a constructor that takes two arguments to initialize width and height.
Include a member function named area that returns the area of the rectangle.
Include a member function named perimeter that returns the perimeter of the rectangle.
Finally, in the main function, create an object of the Rectangle class, and display the area and perimeter of the rectangle.
Write the complete C code that fulfills these requirements.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
