home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 11-2.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  936b  |  38 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 TaxFormFramework {
  7. public:
  8.     TaxFormFramework(int numberOfLines) {
  9.         . . . .
  10.     }
  11.     void draw() {
  12.         makeField(loc1, taxpayer.name());
  13.         makeField(loc2, taxpayer.ssn());
  14.         . . . .
  15.         addFields();
  16.     }
  17. private:
  18.     void makeField(Point, const char *const);
  19.     // derived class must have its own version of addFields
  20.     virtual void addFields() = 0;
  21.     Point loc1, loc2, . . . .
  22.     . . . .
  23. };
  24.  
  25. class ScheduleB: public TaxFormFramework {
  26. public:
  27.     ScheduleB(): TaxFormFramework(14) { }
  28. private:
  29.     Point locA, . . . .
  30.     void addFields() {
  31.         // add the lines for Schedule B
  32.         makeField(locA, mortgage.income());
  33.         makeField(locB, other.income());
  34.         . . . .
  35.     }
  36.     . . . .
  37. };
  38.