Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include Circle.h int Circle::numberOfObjects = 0; // Construct a default circle object Circle::Circle() { radius = 1; numberOfObjects++; } // Construct a circle object Circle::Circle(double
#include "Circle.h"
int Circle::numberOfObjects = 0;
// Construct a default circle object
Circle::Circle()
{
radius = 1;
numberOfObjects++;
}
// Construct a circle object
Circle::Circle(double radius)
{
this->radius = radius;
numberOfObjects++;
}
// Return the area of this circle
double Circle::getArea() const
{
return radius * radius * 3.14159;
}
// Return the radius of this circle
double Circle::getRadius() const
{
return radius;
}
// Set a new radius
void Circle::setRadius(double radius)
{
this->radius = (radius >= 0) ? radius : 0;
}
int Circle::getNumberOfObjects()
{return numberOfObjects;}
Circle::~Circle() {numberOfObjects--;}
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