home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 6-4.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  1KB  |  51 lines

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