Question: in c + + the code is not in its most functional programing state please refactor the program #include class Rectangle { public: int width;

in c++ the code is not in its most functional programing state please refactor the program #include class Rectangle { public: int width; int height; int area(){ return width * height; } int perimeter(){ return 2*(width + height); }}; class Square { public: int side; int area(){ return side * side; } int perimeter(){ return 4* side; }}; int main(){ Rectangle rect; rect.width =4; rect.height =5; Square sq; sq.side =3; std::cout << "Rectangle area: "<< rect.area()<< std::endl; std::cout << "Square area: "<< sq.area()<< std::endl; 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 Programming Questions!