Create a "Rectangle" class with "length" and "width" private member variables. The class needs two public member functions: set_dimension() to set the rectangle's length and width to compute its area Create two Rectangle objects in your main function and ask the user for their length and width. Set rectangle length and width using member functions. Compare the rectangles' areas and print out which is larger. Example of programme execution: Rectangle #1's dimensions: 5 4 Rectangle #2's dimensions: 7 3 Larger rectangle #2!
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create a "Rectangle" class with "length" and "width" private member variables. The class needs two public member functions: set_dimension() to set the rectangle's length and width to compute its area Create two Rectangle objects in your main function and ask the user for their length and width. Set rectangle length and width using member functions. Compare the rectangles' areas and print out which is larger. Example of programme execution: Rectangle #1's dimensions: 5 4 Rectangle #2's dimensions: 7 3 Larger rectangle #2!
Step by step
Solved in 4 steps with 2 images