Listing 1

// meal1.cxx - first attempt at OOP design
#include <stream.h>

enum ENTREE {SteakPlatter,Fish};
enum DESSERT {Pie,Cake,Jello};
enum APPETIZER {Melon,ShrimpCocktail};
class Dessert
   {
   int kind;
public:
   Dessert{int what=Pie) { kind = what;}
   cost();
   };

class Entree
   {
   int kind;
public:
   Entree{int what=SteakPlatter) { kind = what;}
   cost();
   };

class Appetizer
   {
   int kind;
public:
   Appetizer(int what=Melon) { kind = what;}
   cost();
   };

class Meal
   {
   Appetizer a;
   Entree e;
   Dessert d;
public:
   Meal{APPETIZER=Melon,ENTREE=Fish,DESSERT=Jello);
   cost();
   };

//-------------------------------------------
// class member function definitions

int Meal::cost() {return 1;}
Meal::Meal(APPETIZER aval,ENTREE eval,DESSERT dval)
        : a(aval),e(eval),d(dval) { }

//--------------------------------------------
main()
   {
   Meal m(Melon,Fish,Jello);
   printf("Price %d\n",m.cost());
   }