1. 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
2- Add a default constructor to the Circle class in question
(1). The constructor should
initialize the radius member to 0.
3. Add an overloaded constructor to the Circle class in question
(2). The constructor
should accept an argument and assign its value to the radius member
variable.
4. Write a statement that defines an array of five objects of
the Circle class in question
(3). Let the default constructor execute for each element of the
array.
5. Write a statement that defines an array of five objects of
the Circle class in question
(3). Pass the following arguments to the elements’ constructor: 12,
7, 9, 14, and 8.
6. Write a for loop that displays the radius and area of the
circles represented by the
array you defined in question (5).
1. Write a class declaration named Circle with a private member variable named radius. Write set and get functions to ac
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am