/
6-4.C
50 lines (43 loc) · 1.13 KB
/
6-4.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright (c) 1992 by AT&T Bell Laboratories. */
/* Advanced C++ Programming Styles and Idioms */
/* James O. Coplien */
/* All rights reserved. */
class Name { public: Name(const char *); /* . . . . */ };
class Employee {
public:
virtual char *name();
Employee(Name);
private:
// . . . .
};
class Manager: public Employee {
public:
Manager(Name n): Employee(n) { }
protected:
class Secretary: public Employee {
public:
Secretary(Name n) : Employee(n) { }
char *name();
};
};
class VicePresident: public Manager {
public:
VicePresident(Name me, Name Asst, Name sec1, Name sec2);
private:
Secretary SEC1obj, SEC2obj;
class AdminAsst: public Employee {
// . . . .
} AsstObj;
};
class DeptHead: public Manager {
public:
DeptHead(Name me, Name secy): Manager(me), SECobj(secy) { }
private:
Secretary SECobj;
};
VicePresident::VicePresident(Name me, Name Asst, Name sec1, Name sec2):
Manager(me), SEC1obj(sec1), SEC2obj(sec2),
AsstObj(Asst) { }
Manager::Secretary Sam("Sam");
VicePresident Pat("Pat", "Terry", "Jean", "Marion");
DeptHead Jo("Jo", "Chris");