목록으로 2012.11.29. 14:09
C언어

백업

youtube

#include <iostream>
#include<string>
#include <fstream>
using namespace std;
/*
class PFigure
{
    public :
        PFigure();
        void SetColor(const string color);
        string GetColor();
    private :
        string color;
};

class Circle : public PFigure
{
    public :
        Circle();
        void SetR(const double r);
        double GetArea();
    private :
        double r, area;
};

PFigure::PFigure() { this->color="white"; }  // color를 white로 초기화

void PFigure::SetColor(const string color) { this->color=color; }

string PFigure::GetColor() { return color; }

Circle::Circle() { this->r=0;this->area=0; }  // 반지름은 0으로, 넓이는 0으로 초기화

void Circle::SetR(const double r) {this->r=r; }

double Circle::GetArea()
{


          // 넓이 계산

    return area;

}

int main()
{
    PFigure cir1;  // PFigure 객체 cir1 생성

    cout << cir1.GetColor() << endl;  // cir1의 색깔 출력

    cir1.SetColor("red");  // cir1의 색깔을 red로 변경

     cout << cir1.GetColor() << endl;

    Circle cir2;       

    cout << cir2.GetArea() << endl;  // cir2의 넓이
}
 
*/

class GeometricFigure
{
    protected :
        string color;
    public :
        GeometricFigure();
        GeometricFigure(const string);
        void SetColor(const string);
        bool IsPaint();
        string GetColor();
};

GeometricFigure::GeometricFigure() { this->color="white";  } // color를 white로 초기화

GeometricFigure::GeometricFigure(const string c)  { color=c;  }

void GeometricFigure::SetColor(const string c) { color=c; }

bool GeometricFigure::IsPaint() {
        if (color=="white")    return false;
        else                          return true;
}
string GeometricFigure::GetColor() { return color; }

int main()
{
    GeometricFigure obj1;

    cout << "obj1의색: " << obj1.GetColor() << endl;

    obj1.SetColor("green");   // obj1의 색깔을 green으로 변경

    cout << "obj1의색: " << obj1.GetColor() << endl;
}

댓글 0

댓글 작성 권한이 없습니다. 로그인하기

NO
TITLE
섬네일
C언어
profile 너에게제공 | 03. 13 | 조회
71
C언어 kg->g
profile 너에게제공 | 12. 21 | 조회
70
E비즈니스
2 | 12. 20 | 조회
69
E비즈니스 javascript:void(0);
XML
profile 너에게제공 | 12. 14 | 조회
68
XML s
XML
asf | 12. 14 | 조회
67
XML XML
C언어
nn | 12. 13 | 조회
66
C언어 ver1 ,2 ,3
E비즈니스
profile 너에게제공 | 12. 10 | 조회
65
E비즈니스 스마트메뉴
profile 너에게제공 | 12. 07 | 조회
64
XML | 12. 07 | 조회
63
C언어
profile 너에게제공 | 12. 06 | 조회
61
C언어 ver2
E비즈니스
profile 너에게제공 | 12. 03 | 조회
60
E비즈니스 r견적
XML
s | 11. 30 | 조회
59
XML asd