#ifndef SETH #define SETH #include #include #include using namespace std; //T must be copy constructable and equality comparable. //CONTAINER must have const_iterator, begin, end, push_back. template > //needs whitespace class set { CONTAINER c; public: bool find(const T& t) const { for (typename CONTAINER::const_iterator it = c.begin(); it != c.end(); ++it) { if (*it == t) { return true; } } return false; } void insert(const T& t) { if (find(t)) { cerr << "Sorry, the value is already in the set.\n"; exit(EXIT_FAILURE); } c.push_back(t); } }; #endif