// client (driver) program to test template class Set #include "Set.cpp" #include "SetIter.cpp" #include #include using std::endl; using std::cout; int main() { Set < int >is1, is2; is1.add(3); is1.add(5); is1.add(-40); if (!is1.add(5)) cout << "can't add 5 to is1" << endl; cout << "is1: " << is1 << endl; is2 = is1; is2.add(0); if (is1.remove(5)) cout << "removed 5 from is1" << endl; is2.add(101); is2.add(-50); is2.add(3); is2.add(200); cout << "is1: " << is1 << endl; cout << "is2: "; is2.display(cout) << endl; is2.remove(200); is2.remove(-50); is2.remove(3); cout << "is2: " << is2 << endl; Set < string > sset; sset.add("hello"); sset.add("happy"); sset.add("day"); sset.add("whatever"); cout << "sset: " << sset << endl; Set < string > ssetcopy(sset); cout << "ssetcopy: " << ssetcopy << endl; ssetcopy.remove("happy"); ssetcopy.add("HAPPY"); ssetcopy.remove("whatever"); cout << "ssetcopy: " << ssetcopy << endl; SetIter < int >iter(is1); double avg = 0; while (iter.hasNext()) { avg += iter.next(); } cout << "avg of is1 is " << avg / is1.size() << endl; }