C언어 B
너에게제공
397 0 0
#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; } |