1: Based on Program 13-1 in the textbook, create a class name “Circle” with the following declarations by completing missing methods. (Hint: you can use PI=3.14.) //Circle class declaration class Circle { private: double radius; public: void setRadius(double); double getRadius() const; double getArea() const; double getPerimeter() const;
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
1: Based on Program 13-1 in the textbook, create a class name “Circle” with the following declarations by completing missing methods.
(Hint: you can use PI=3.14.)
//Circle class declaration
class Circle
{
private:
double radius;
public:
void setRadius(double);
double getRadius() const;
double getArea() const;
double getPerimeter() const;
};
Answer:
Algorithms:
Step1: we have initialize PI as globally
Step2: then we have create a class circle and declared as data member and member function to set the value of radius and return the area of circle and return the perimeter of the circle
Step3: From the main function we have initialized the two object as obj1 and obj2
Step4: then call the created member function to print the area and perimeter of the circle
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images