Question: C++ Create a class definition and implementation for a class named Circle with a private double member variable, radius. This class should have a constructor

C++

Create a class definition and implementation for a class named Circle with a private double member variable, radius.

This class should have a constructor with a defaulted radius parameter of 1. The body of the constructor should call the setRadius setter function passing the constructor parameter as an argument.

The class should have a setter function, setRadius with a double variable parameter. The function should set the member variable radius to the parameter of the function.

The class should have a getter function, getRadius. The function should have no parameters and return the privatevariable, radius.

Also define two functions, getArea() and getPerimeter() with the appropriate formulas. These functions should be value-returning and should return the area and perimeter of the circle based on the private member radius. Set PI to be 3.14.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!