Related questions with answers
Question
Write a class declaration named Circle with a private member variable named radius. Write set and get functions to access the radius variable, and a function named getArea that returns the area of the circle. The area is calculated as 3.14159 * radius * radius
Solutions
VerifiedSolution A
Solution B
Answered 3 months ago
Step 1
1 of 2class Circle{
private:
double radius;
public:
//function to get radius
//it is declared const because it
//will not change the calling object
//in any manner
double getRadius() const{
return radius;
}
//function to set radius
//accepts an argument of type double
//and sets it to the radius member
void setRadius(double r){
radius = r;
}
//function to get area
//declared const for the same reasons
//as above
double getArea() const{
return 3.14159 * radius * radius;
}
};
Answered 3 months ago
Step 1
1 of 4First let us view the UML to make things easier,
Here is a review of the used notations, that (-
) represents a private
member, while (+
) represents a public member
The format of the arguments & members is argName : dataType
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Recommended textbook solutions

Computer Organization and Design MIPS Edition: The Hardware/Software Interface
5th Edition•ISBN: 9780124077263 (6 more)David A. Patterson, John L. Hennessy220 solutions

Starting Out with C++ from Control Structures to Objects
8th Edition•ISBN: 9780133769395 (11 more)Godfrey Muganda, Judy Walters, Tony Gaddis1,294 solutions

Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777 (1 more)Ramez Elmasri, Shamkant B. Navathe687 solutions

Introduction to Algorithms
3rd Edition•ISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen726 solutions
More related questions
1/2
1/3