home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_12 / 9n12116a < prev    next >
Text File  |  1991-10-21  |  658b  |  29 lines

  1. /* LISTING 7 - CIRCLE.C */
  2. #include "obj.h"
  3.  
  4. /* get the color */
  5. static int circle_getcolor(CIRCLE *pc)  
  6.    {   return pc->color;   }
  7.  
  8. /* set color */
  9. static int circle_setcolor(CIRCLE *pc,
  10.                      int color) 
  11.    {   return (pc->color = color);   }
  12.  
  13. /* create an "action package" for CIRCLEs */
  14. static CIRCLE_ACTIONS cact = 
  15.    {circle_setcolor, circle_getcolor};
  16.  
  17. /* and a "constructor" for a new circle */
  18. constructor(CIRCLE *pc, int color)
  19.    {
  20.    pc->color = color;
  21.  
  22.    /* constructor can access the private
  23.           action package! */
  24.  
  25.    /* constructor hooks up actions */
  26.    pc->pcact = &cact;        
  27.    }
  28.  
  29.