#include #include #include class user { protected : int code; char name[20]; public : user() { code=0; strcpy(name,""); } user(int code0, char *name0) { code = code0; strcpy(name,name0); } int getcode() { return code; } char * getname() { return name; } void setcode(int code0) { code = code0; } void setname(char name0[20]) { strcpy(name,name0); } void display_data() { cout << " Code = " << code << endl; cout << " Onoma = " << name << endl; } void readdata() { cout << "Give code :"; cin >> code; cout << "Give name :"; cin >> name; } }; class usage : public user { private : char usage_date[10]; int computer_code; float duration; float charge; public : usage():user() { strcpy(usage_date,""); computer_code =0; duration =0 ; charge =0; } usage(int code0, char *name0, char *udate0, int c_c, float duration0, float charge0): user(code0, name0) { strcpy(usage_date,udate0); computer_code =c_c; duration =duration0 ; charge = charge0; } char * get_usage_date() { return usage_date; } int get_computer_code() { return computer_code; } float get_duration() { return duration; } float get_charge() { return charge; } void set_usage_date(char *ud0) { strcpy(usage_date,ud0); } void set_computer_code(int cc0) { computer_code = cc0; } void set_duration(float dur0) { duration = dur0; } void set_charge(float charge0) { charge =charge0; } void display_data() { user :: display_data(); cout << "Usage date = " << usage_date << endl; cout << "Computer code = " << computer_code << endl; cout << "Duration = " << duration << endl; cout << "Charge = " << charge << endl; } void read_data() { user::readdata(); cout << "Give Usage Date :"; cin >> usage_date; cout << "Give computer code :"; cin >> computer_code; cout << "Give duration :"; cin >> duration; //cout << "Give charge :"; //cin >> charge; } void calculate_charge() { charge = (duration/60)*1.2; } }; main() { usage *a[500],a0; usage a1(1,"Theo Lantzos","15/1/2010",16,1.30,3); a1.display_data(); cout << "==============" << endl; a0.display_data(); a0.read_data(); a0.calculate_charge(); a0.display_data(); cout << sizeof(a); cout << endl << 500 * sizeof(a1); getch(); }