You can`t implement operator<< as a method of class, it has to be a global function!
Your operator <<
doesn`t work at all, because in method implementation always first implicit argument is this so you implementation is analog to the function with the following signature:
ostream& operator<< (this, ostream& );
but to make operator <<
work - first argument should be ostream&
implement operator as global function and you issue will be solved:
ostream& operator<< ( ostream& str, iterator& iter );
in this part of the code you simply dereference iterator (operator* is invoked)
Set::Iterator it = s1.begin();
while( it != s1.end() ){
cout << *it;
it++;
}
if you need to call operator<< rewrite it:
Set::Iterator it = s1.begin();
while( it != s1.end() ){
cout << it;
it++;
}