Question
Does any can help me to fix this program ? #include using namespace std; //Creating Rectangle class class Rectangle { private : //Declaring variables float
Does any can help me to fix this program ?
#include
using namespace std;
//Creating Rectangle class
class Rectangle
{
private :
//Declaring variables
float length;
float width;
public:
Rectangle();
Rectangle(float length, float width);
//Function declarations
void setLength(float length);
void setWidth(float width);
float perimeter();
float area();
void show();
int sameArea(Rectangle);
};
//Zero argumented cosntructor
Rectangle::Rectangle()
{
}
//Parameterized cosntructor
Rectangle::Rectangle(float length, float width)
{
this->length=length;
this->width=width;
}
//Function implementations
void Rectangle::setLength(float length)
{
this->length=length;
}
void Rectangle::setWidth(float width)
{
this->width=width;
}
float Rectangle::perimeter()
{
return 2*(this->length+this->width);
}
float Rectangle::area()
{
return (this->length*this->width);
}
void Rectangle::show()
{
cout<<"Length = "< } Rectangle& operator ++(int){ length++; width++; return this; } bool operator==(Rectangle R1){ if(this->length==r1.length&& this->width==r1.width) return true; else return false; } } int main() { //Declaring variables float length,width; //Creating an obejct to Rectangle r1 Rectangle r1(5.5,6.5); //Creating an obejct to Rectangle r2 Rectangle r2; //Getting the values entered by the user cout<<"Enter the Length of the Rectangle :"; cin>>length; cout<<"Enter the Width of the Rectangle :"; cin>>width; //Setting the length and width of the rectangle r2 r2.setLength(length); r2.setWidth(width); cout<<"Rectangle r1 :"; r1.show(); cout<<"Rectangle r2 :"; r2.show(); /* calling the function to compare * the area of rectangle r1 and r2 */ if(r1==R1) cout<<"The Rectangle r1 and Rectangle r2 having same area ."< else cout<<"The Rectangle r1 and Rectangle r2 not having same area ."< ///Displaying the area and perimeter of rectangle r1 and r2 cout<<"Area of the Rectangle r1:"< cout<<"Area of the Rectangle r2:"< cout<<"Perimeter of the Rectangle r1:"< cout<<"Perimeter of the Rectangle r2:"< return 0; }
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