write the definition of the class Rectangle containing: length: a private data member of type double width: a private data member of type double a default constructor that assigns the values 20 and 10 length and width, respctively. an overloading constructor that accepts two parameters of type double and assigns them to length and width. an overloading constructor that accepts one parameter of type double and assigns it to both length and width setLength: a member function that accepts a double parameter and assigns it to length if it is positive(gerater than zero). setWidth: a member function that accepts a double parameter and assigns it to width if it is positive(gerater than 0) getLength: a member function that accepts no parameter and returns the value of length getWidth: a meber function that accepts no parameters and returns the value of width getAre: a member function that accepts no parameters and returns the area of the rectangle.
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:
write the definition of the class Rectangle containing:
length: a private data member of type double
width: a private data member of type double
a default constructor that assigns the values 20 and 10 length and width, respctively.
an overloading constructor that accepts two parameters of type double and assigns them to length and width.
an overloading constructor that accepts one parameter of type double and assigns it to both length and width
setLength: a member function that accepts a double parameter and assigns it to length if it is positive(gerater than zero).
setWidth: a member function that accepts a double parameter and assigns it to width if it is positive(gerater than 0)
getLength: a member function that accepts no parameter and returns the value of length
getWidth: a meber function that accepts no parameters and returns the value of width
getAre: a member function that accepts no parameters and returns the area of the rectangle.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images