home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 9-3.H < prev    next >
C/C++ Source or Header  |  1991-12-04  |  1KB  |  43 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 Letter: public Thing {
  7. public:
  8.     /* all user-defined operators go here.  Note that, because
  9.      * of the use of operator->, this signature does not have
  10.      * to be mimicked in the Envelope.  However, the Envelope's
  11.      * rep field has to be appropriately typed.  Assignment
  12.      * operators do not go here, but in the Envelope.
  13.      *
  14.      * return_type should either be a primitive
  15.      * type, or of type Envelope, of type Envelope&, or
  16.      * a concrete data type
  17.      */
  18.     virtual void send(String name, String address);
  19.     virtual double postage();
  20.     // virtual return_type user-defined-function
  21.     // . . . .
  22.     virtual Envelope make();          // constructor
  23.     virtual Envelope make(double);    // another constructor
  24.     virtual Envelope make(int days, double weight);
  25.     virtual Thing *cutover(Thing*);  // run-time update function
  26.     Letter() { }
  27.     ~Letter() { }
  28.     Thing *type();
  29. protected:
  30.     friend class Envelope;
  31.     double ounces;
  32.     static void *operator new(size_t l) {
  33.         return ::operator new(l);
  34.     }
  35.     static void operator delete(void *p) {
  36.         ::operator delete(p);
  37.     }
  38.     String name, address;
  39.     // . . . .
  40. private:
  41.     // . . . .
  42. };
  43.