// catalog.cpp: implementation of the Catalog class. // ////////////////////////////////////////////////////////////////////// #include "catalog.h" void Catalog::Add(const Item & I) // Add a new item to the catalog { m_vItems.push_back( I ); } list::iterator Catalog::Find( const Item & anItem ) { list::iterator I; for( I = m_vItems.begin(); I != m_vItems.end(); I++) { if( *I == anItem ) // Item must overload the == operator return I; // found a match } return NULL; // failed to find a match } void Catalog::Remove( list::iterator I ) // Remove a single list node. This will cause a // runtime error if the iterator is invalid. { if( I != NULL ) { m_vItems.erase( I ); // good luck! } } ostream & operator<<( ostream & os, const Catalog & C ) // Stream output operator { list::const_iterator I; for( I = C.m_vItems.begin(); I != C.m_vItems.end(); I++) os << *I << endl; return os; }