Course Solutions Uncategorized (Solved) : C Make Class Generic Sides Shape May Integer Float Include Using Namespace Std Shape Squar Q34451316 . . . .

(Solved) : C Make Class Generic Sides Shape May Integer Float Include Using Namespace Std Shape Squar Q34451316 . . . .

 

C++

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

#include <iostream>
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: “<<getSide()<<endl;
cout<<“Area: “<<getArea()<<endl;
cout<<“Perimeter: “<<getPerimeter();
}
};

int main()
{
shape S;
int num;

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

if(!S.setSides(num))
cout<<“Entered side is not validn”;

S.display();

return 0;
}

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : Business Data Communications Question 20 Control Done Individual Switches Routers O Tradit Q31000914 . . . .(Solved) : Business Data Communications Question 20 Control Done Individual Switches Routers O Tradit Q31000914 . . . .

<br/><img src="https://media.cheggcdn.com/media%2F1ec%2F1ecb5b09-b264-4a01-945c-65afc9a0e2b4%2Fimage" alt="Business Data Communications QUESTION 20 Control is done on individual switches and routers in O traditional operation O SDN O both A and B O neither A nor

(Solved) : Hi Getting Error Compiling C Maincpp Code Would Mind Telling Could Problem Code Locationh Q30592210 . . . .(Solved) : Hi Getting Error Compiling C Maincpp Code Would Mind Telling Could Problem Code Locationh Q30592210 . . . .

<p>Hi I am getting an error when compiling my C++ main.cppcode.</p><p>Would you mind telling me what could be the problem?</p><p><strong>Code:</strong></p><p><strong>Location.h</strong></p>#ifndef _LOCATION_H_#define _LOCATION_H_#include<iostream><strong>using</strong> <strong>namespace</strong> std;<strong>class</strong> Location{ <strong>public</strong> :