class person
{ protected:
char *name, *ident, *address, *phone;
public:
person(char *n, char *i, char *a, char *p);
char *get_name(void) { return name; }
char *get_ident(void) { return ident; }
char *get_address(void) { return address; }
void set_address(char *a) { address=new char[strlen(a)+1]; strcpy(address,a); }
void set_phone(char *p) { phone=new char[strlen(p)+1]; strcpy(phone,p); }
void print(void) { printf("Person #%s, %s of %s, %s\n", ident, name, address, phone); } };
person::person(char *n, char *i, char *a, char *p)
{ name=new char[strlen(n)+1]; strcpy(name,n);
ident=new char[strlen(i)+1]; strcpy(ident,i);
address=new char[strlen(a)+1]; strcpy(address,a);
phone=new char[strlen(p)+1]; strcpy(phone,p); } |
class customer: public person
{ protected:
int rating, balance;
public:
customer(char *n, char *i, char *a, char *p, int r, int b): person(n,i,a,p)
{ rating=r; balance=b; }
int get_rating(void) { return rating; }
void set_rating(int r) { rating=r; }
int get_balance(void) { return balance; }
void set_balance(int b) { balance=b; }
void print(void)
{ printf("Customer #%s, %s of %s, %s, rating=%d, balance=%d\n",
ident, name, address, phone, rating, balance); } }; |
customer(char *n, char *i, char *a, char *p, int r, int b)
{ person(n,i,a,p);
rating=r; balance=b; } |
customer(char *n, char *i, char *a, char *p, int r, int b)
{ rating=r; balance=b; } |
class customer: public person
{ protected:
char *jobtitle, *supervisor;
int salary;
public:
employee(char *n, char *i, char *a, char *p, char *j, char *s, int sal): person(n,i,a,p);
char *get_jobtitle(void) { return jobtitle; }
void set_jobtitle(char *j) { jobtitle=new char[strlen(j)+1]; strcpy(jobtitle,j); }
char *get_supervisor(void) { return supervisor; }
void set_supervisor(char *s) { supervisor=new char[strlen(s)+1]; strcpy(supervisor,s); }
int get_salary(void) { return salary; }
void set_salary(int s) { salary=s; }
void give_raise(int percent) { salary=salary*(100+percent)/100; }
void print(void)
{ printf("Employee #%s, %s of %s, %s,\n%s, supervisor %s, salary=%d\n",
ident, name, address, phone, jobtitle, supervisor, salary); } };
employee::employee(char *n, char *i, char *a, char *p, char *j, char *s, int sal)
{ jobtitle=new char[strlen(j)+1]; strcpy(jobtitle,j);
supervisor=new char[strlen(s)+1]; strcpy(supervisor,s);
salary=sal; } |