Created
August 7, 2020 02:06
-
-
Save iqfareez/28b74e50f83393097e604b658619bd6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#define PI 3.142 | |
class circle{ | |
private: | |
double radius; | |
public: | |
circle(); | |
circle(double); | |
~circle(); | |
void setRadius(double); | |
double getRadius() const{ | |
return radius; | |
} | |
double getArea() const{ | |
return PI*radius*radius; | |
} | |
double getPerimeter() const{ | |
return 2*PI*radius; | |
} | |
}; | |
circle::circle(){ | |
radius = 0; | |
} | |
circle::circle(double r){ | |
radius = r; | |
} | |
circle::~circle(){ | |
cout << "calling destructor" << endl; | |
} | |
int main(){ | |
circle c1; | |
cout << c1.getRadius() << endl; | |
circle c2(3.3); | |
cout << c2.getRadius() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment