Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Circle{
- private:
- double radius;
- string color;
- public:
- Circle()
- {
- radius=1.0;
- color="red";
- }
- Circle(double r,string c)
- {
- radius=r;
- color=c;
- }
- double getRadius(){
- return radius;
- }
- void setRadis(double rad){
- radius=rad;
- }
- string getColor()
- {
- return color;
- }
- void setColor(string col)
- {
- color=col;
- }
- double getArea()
- {
- return 3.14159*radius*radius;
- }
- };
- int main()
- {
- Circle krug;
- krug.setRadis(1.2);
- cout<<"Radius="<<krug.getRadius()<<" Area="<<krug.getArea()<<" Color="<<krug.getColor()<<endl;
- Circle krug1(2.1,"blue");
- cout<<"Radius="<<krug1.getRadius()<<" Area="<<krug1.getArea()<<" Color="<<krug1.getColor()<<endl;
- Circle krug2;
- cout<<"Radius="<<krug2.getRadius()<<" Area="<<krug2.getArea()<<" Color="<<krug2.getColor()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement