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 = "<length<<" Width = "<width<

}

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!