목록으로 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
섬네일
6 | 10. 11 | 조회
13
8 | 10. 11 | 조회
11
r23r | 10. 11 | 조회
9
profile 너에게제공 | 10. 04 | 조회
7
s | 10. 04 | 조회
6
s | 10. 04 | 조회
5
profile 너에게제공 | 10. 04 | 조회
4
profile 너에게제공 | 10. 04 | 조회
3