목록으로 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언어
s | 11. 15 | 조회
43
C언어 s
C언어
profile 너에게제공 | 11. 15 | 조회
42
C언어 c++ 11/15
profile 너에게제공 | 11. 15 | 조회
41
E비즈니스
| 11. 15 | 조회
40
E비즈니스 블랙리스트
E비즈니스
| 11. 11 | 조회
38
E비즈니스 위생정리
profile 너에게제공 | 11. 09 | 조회
36
profile 너에게제공 | 11. 09 | 조회
35
C언어
profile 너에게제공 | 11. 08 | 조회
34
C언어 ㅇ_ㅇ
C언어
df | 11. 08 | 조회
33
C언어 df
s | 11. 08 | 조회
32
E비즈니스
profile 너에게제공 | 11. 05 | 조회
31
E비즈니스 맞춤형안경
profile 너에게제공 | 11. 01 | 조회
29