home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 4-5.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  1KB  |  52 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 Telephone {
  7. public:
  8.     enum PhoneType { POTS, ISDN, OPERATOR, OTHER } phoneType()
  9.         { return phoneTypeVal; }
  10.     void ring();
  11.     Bool isOnHook();
  12.     Bool isTalking();
  13.     Bool isDialing();
  14.     DigitString collectDigits();
  15.     LineNumber extension();  // not overridden below
  16.     ~Telephone();
  17. protected:
  18.     LineNumber extensionData;
  19.     PhoneType phoneTypeVal;
  20.     Telephone();
  21. };
  22.  
  23. .iX "\&\f4POTSPhone\fP\& (\*C class)" "and type selector fields"
  24. class POTSPhone: public Telephone {
  25. public:
  26.     Bool runDiagnostics();
  27.     POTSPhone(): phoneTypeVal(POTS) . . . .  {
  28.         . . . .
  29.     }
  30.     POTSPhone(POTSPhone &p): phoneTypeVal(POTS) . . . .  {
  31.         . . . .
  32.     }
  33.     ~POTSPhone();
  34. private:
  35.     Frame frameNumberVal;
  36.     Rack rackNumberVal;
  37.     Pair pairVal;
  38. };
  39.  
  40. class ISDNPhone: public Telephone {
  41. public:
  42.     ISDNPhone(): phoneTypeVal(ISDN) . . . .   {  . . . .  }
  43.     ISDNPhone(ISDNPhone &p): phoneTypeVal(ISDN) . . . . {
  44.         . . . .
  45.     }
  46.     ~ISDNPhone();
  47.     void sendBPacket();  // send a packet on the B channel
  48.     void sendDPacket();  // send a packet on the D channel
  49. private:
  50.     Channel b1, b2, d;
  51. };
  52.