목록으로 2012.11.29. 15:15
C언어

B

youtube
#include<iostream>
#include<string>
using namespace std;

class Person
{
private:
        string name, addr, phone;
public:
        Person(){name=""; addr=""; phone="";}
        void setName(string n){name=n;}
        void setAddr(string a){addr=a;}
        void setPhone(string p){phone=p;}

        string getName(){return name;}
        string getAddr(){return addr;}
        string getPhone(){return phone;}
};

class Customer : public Person
{
private:
        string cusno; int mile;
public:
        Customer(){cusno=""; mile=0;}
        void setCusno(string c){cusno=c;}
        void setMile(int m){mile=m;}

        string getCusno(){return cusno;}
        int getMile(){return mile;}
};

int main()
{
        Person p1;
        p1.setName("강하늘");
        p1.setAddr("서울시");
        p1.setPhone("02-123-1230");
        cout<<"이름 : "<<p1.getName()<<", 주소 :"<<p1.getAddr()<<
                ", 전화번호 : "<<p1.getPhone()<<endl;
        Customer c1;
        c1.setName("이겨울");
        c1.setAddr("인천");
        c1.setPhone("032-123-6040");
        c1.setCusno("c-100");
        c1.setMile(500);
        cout<<"이름 : "<<c1.getName()<<", 주소 :"<<c1.getAddr()<<
                ", 전화번호 : "<<c1.getPhone()<<"n"<<"고객번호 :"<<
                c1.getCusno()<<", 마일리지 :"<<c1.getMile()<<"n"<<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