목록으로 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 너에게제공 | 11. 29 | 조회
57
C언어 B
C언어
profile 너에게제공 | 11. 29 | 조회
56
C언어 A
C언어
profile 너에게제공 | 11. 29 | 조회 369
55
C언어 백업
| 11. 27 | 조회
54
XML
124 | 11. 23 | 조회
53
XML 124
XML
dqw | 11. 23 | 조회
52
XML 124
profile 너에게제공 | 11. 23 | 조회
51
profile 너에게제공 | 11. 23 | 조회
50
C언어
asf | 11. 23 | 조회
49
C언어 af
C언어
profile 너에게제공 | 11. 22 | 조회
48
C언어 실습
C언어
| 11. 22 | 조회
47
C언어
C언어
profile 너에게제공 | 11. 22 | 조회
46
C언어 ㄹㅈ
C언어
profile 너에게제공 | 11. 22 | 조회
45
C언어 BMI
JSP
전장호 | 11. 21 | 조회
44
JSP f