Figure 9 Delaying creation of an object by restricting access

class BMOJoin;

class BMOIteratorImp {
public:
  BMOIteratorImp()
  {
    itsJoinPtr = NULL;
  }
  ~BMOIteratorImp()
  {
    delete itsJoinPtr;
  }
  int Search(char *str)
  {
    return
      GetJoinPointer()->Search(str);
  }
  void Disconnect()
  {
    delete itsJoinPtr;
    itsJoinPtr = NULL;
  }
private:
// this is actually split apart
// (see Figure 4.
)
  BMOJoin *GetJoinPointer()
  {
    if(itsJoinPtr)
      return itsJoinPtr;
    itsJoinPtr = new
      BMOJoin(itsStoredParameters);
    if(itsJoinPtr == NULL)
// for now throw is just an inline
// for exit()
      throw(ErrNoMem);
    return itsJoinPtr;
  }
};

// End of File