home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_08 / 8n08049a < prev    next >
Text File  |  1990-07-18  |  1KB  |  57 lines

  1. // meal1.cxx - first attempt at OOP design
  2. #include <stream.h>
  3.  
  4. enum ENTREE {SteakPlatter,Fish};
  5. enum DESSERT {Pie,Cake,Jello};
  6. enum APPETIZER {Melon,ShrimpCocktail};
  7.  
  8. class Dessert
  9.     {
  10.     int kind;
  11. public:
  12.     Dessert(int what=Pie) { kind = what;}
  13.     cost();
  14.     };
  15.  
  16. class Entree
  17.     {
  18.     int kind;
  19. public:
  20.     Entree(int what=SteakPlatter) { kind = what;}
  21.     cost();
  22.     };
  23.  
  24. class Appetizer
  25.     {
  26.     int kind;
  27. public:
  28.     Appetizer(int what=Melon) { kind = what;}
  29.     cost();
  30.     };
  31.  
  32. class Meal 
  33.     {
  34.     Appetizer a;
  35.     Entree e;
  36.     Dessert d;
  37. public:
  38.     Meal(APPETIZER=Melon,ENTREE=Fish,DESSERT=Jello);
  39.     cost();
  40.     };
  41.  
  42. //-------------------------------------------
  43. // class member function definitions
  44.  
  45. int Meal::cost() {return 1;}
  46. Meal::Meal(APPETIZER aval,ENTREE eval,DESSERT dval)
  47.          : a(aval),e(eval),d(dval) { }
  48.  
  49. //--------------------------------------------
  50.  
  51. main()
  52.     {
  53.     Meal m(Melon,Fish,Jello);
  54.     printf("Price %d\n",m.cost());
  55.     }
  56.  
  57.