#include <iostream>
#include <string.h>
using namespace std;
class B_class {
char name[80];
public:
void put_name(char *s) {strcpy(name, s); }
void show_name(void) {cout << name << " ";}
} ;
class D_class : public B_class {
char phone_num[80];
public:
void put_phone(char *num) {
strcpy(phone_num, num);
}
void show_phone() {cout << phone_num << "\n";}
};
main(void)
{
B_class *p;
B_class B_ob;
D_class *dp;
D_class D_ob;
p = &B_ob;
p->put_name("Thomas Edison");
p = &D_ob;
p->put_name("Albert Einstein");
B_ob.show_name();
D_ob.show_name();
cout << "\n";
dp = &D_ob;
dp->put_phone("555 555-1234");
p->show_name();
dp->show_phone();
return 0;
}
|