Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Make this class generic so that the sides of the shape may be integer or float #include using namespace std; // shape is square

C++

Make this class generic so that the sides of the shape may be integer or float

#include using namespace std;

// shape is square class shape { int side;

public: int getSide() { return side; }

bool setSides(int s) { if(s > 0) { side = s; return true; } else return false; }

int getArea() { return side*side; }

int getPerimeter() { return side*4; }

void display() { cout<<"Side: "<

int main() { shape S; int num;

cout<<"Enter side: "; cin>>num;

if(!S.setSides(num)) cout<<"Entered side is not valid ";

S.display();

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions