Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- class CIRCLE{
- float radius;
- string color;
- public:
- void SetRadius(float dim);
- void SetColor(string clr);
- float GetRadius();
- string GetColor();
- CIRCLE();
- CIRCLE(float dim, string clr);
- CIRCLE (const CIRCLE &s);
- ~CIRCLE();
- friend float Perimeter(CIRCLE *SP);
- float Area();
- };
- void CIRCLE::SetRadius(float dim){
- radius=dim;
- }
- void CIRCLE::SetColor(string clr){
- color=clr;
- }
- float CIRCLE::GetRadius(){
- return radius;
- }
- string CIRCLE::GetColor(){
- return color;
- }
- CIRCLE::CIRCLE(){
- radius=10;
- color="green";
- }
- CIRCLE::CIRCLE(float dim, string clr){
- radius=dim;
- color=clr;
- }
- CIRCLE::CIRCLE(const CIRCLE &s){
- radius=s.radius;
- color=s.color;
- }
- CIRCLE::~CIRCLE(){
- }
- float Perimeter(CIRCLE *s){
- float perimeter;
- perimeter=2*M_PI*s->radius;
- return perimeter;
- }
- float CIRCLE::Area(){
- float area;
- area=M_PI*pow(radius,2);
- return area;
- }
- void Generic1(CIRCLE s){
- }
- CIRCLE Generic2(CIRCLE &s){
- return s;
- }
- class CONE:public CIRCLE{
- float height;
- public:
- void SetHeight(float dim){
- height=dim;
- }
- float GetHeight(){
- return height;
- }
- float Volume(){
- float volume;
- volume=(Area()*height)/3;
- return volume;
- }
- CONE(float dim){
- height=dim;
- }
- };
- int main(int argc, char** argv){
- float r;
- string c;
- cin>>r;
- cin>>c;
- CIRCLE c1(r, c);
- cin>>r;
- CONE c2(r);
- cout<<setprecision(2)<<fixed<<Perimeter(&c1)<<endl;
- cout<<setprecision(2)<<fixed<<c1.Area()<<endl;
- cout<<setprecision(2)<<fixed<<c2.Volume();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement