Question
I need some help with my script please. #include using namespace std; double pi = 3.14; class Circle { private: double radius; public: Circle(); {
I need some help with my script please.
#include
using namespace std;
double pi = 3.14;
class Circle {
private:
double radius;
public:
Circle(); {
radius = 1;
}
Circle(double r) {
radius = r;
}
void setRadius(double r) {
radius = r; {
if (radius != 1)
throw invalid_argument("Invalid value for radius");
else
setRadius(r);
}
}
double getRadius() {
return radius;
}
double getArea() {
return pi * radius*radius;
}
double getDiameter() {
return 2 * radius;
}
double getCircumference() {
return 2 * pi*radius;
}
};
int main() {
Circle c1;
double r;
cout
cout
cout
cout
cout
cin >> r;
c1.setRadius(r);
cout
cout
cout
cout
circle c2(-1);
cout
cout
cout
cout
return 0;
}
Define the class Circle. The Circle class has a private data member radius (double) Define constructors for the Circle class. Include set and get functions for the radius data member. Include a function called area that returns the area of the Circle Overload the operatorStep 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