Listing 7

#include "obj.h"

/* get the color */
static int circle_getcolor(CIRCLE *pc)
   {   return pc->color;   }

/* set color */
static int circle_setcolor(CIRCLE *pc, int color)
   {   return (pc->color = color );   }

/* create an "action package" for CIRCLEs */
static CIRCLE_ACTIONS cact =
   {circle_setcolor, circle_getcolor};

/* and a "constructor" for a new circle */
constructor(CIRCLE *pc, int color)
   {
   pc->color = color;

   /* constructor can access the private action package! */

   /* constructor hooks up actions */
   pc- pcact = &cact;
   }

/* End of File */