Answered step by step
Verified Expert Solution
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
// 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
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