\section{Appendix B}

\begin{verbatim}
// Revised code for evaluating Prefix 
//   expressions 
// code follows the Law of Demeter.
// Class definitions are in section 2.

void Example::eval()
{ exps->top_eval();}
	 
void Prefix_list::top_eval()
// acquaintance: Prefix_list_it
{ Prefix* each_exp;
  Prefix_list_it next_exp(*this);
   while( each_exp = next_exp() )
       {  each_exp->pp();
          cout << " = " 
	       << each_exp->eval();};}

int Prefix_list::apply(Oper* op)
// acquaintance: Prefix_list_it
{ Prefix* each;
  Prefix_list_it next_exp(*this);
  int result = next_exp()->eval();
  while (each = next_exp())
    result = 
       op->apply_op(result,each->eval());
  return result;}

int Prefix::eval() {}

int Compound::eval()
{ return args->apply(op);}

int Oper::apply_op(int num1,int num2) {}

int Number::eval()
{ return this->get_val();}

int Addsym::apply_op(int num1,int num2)
{ return num1 + num2;}

int Mulsym::apply_op(int num1,int num2)
{ return num1 * num2;}

\end{verbatim}


