Question: C++ Create a program that defines a class called circle. Circle should have a member variable called radius that is used to store the radius
C++
Create a program that defines a class called circle. Circle should have a member variable called radius that is used to store the radius of the circle. Circle should also have a member function called calcArea that calculates the area of the circle using the formula area = pi*r^2. Area should NOT be stored in a member variable of circle to avoid stale data.
Use a global constant for PI and set it to 3.14159.
For now, make radius public and access it directly using the dot operator. Do not worry about input validation for now.
In main instantiate two objects of class circle and have the user enter a radius for each. Store the radii in the appropriate objects' member variables, then print the radius and area of each circle using the member variable and function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
