Listing 3

// 2Cache.cpp

class CacheErrors : public ErrorLogger
{
public:
  CacheErrors() {}
  virtual void Error( const string& msg )
  {
    errors_.insert(msg);
  }
  // Log() not overridden, still goes to stdout
  void DumpErrors() const
  {
    copy(errors_.begin(), errors_.end(),
      ostream_iterator<string>(cerr));
  }
private:
  set<string> errors_;
};