friend operator <<

Hi,

I'm having trouble with the friend operator <<. Here is my code:

ostream & operator<<(ostream &os, const list<pair<string,int>> &data){
list<pair<string,int>>::iterator iter;
for(iter=data.begin();iter!=data.end();++iter) os<<data.first<<"("<<data.second<<")";<<"\t"<<endl;
return os;}

it has problems with the line iter=data.begin(), with error no operator found which takes a right-hand operand of type 'std::_List_const_iterator<_Mylist>' (or there is no acceptable conversion)

The iterator works fine in main, with no problems, but when I try to use it in the friend function the problems begin.

Thanks

Chris
You need

 
list< pair< string, int > >::const_iterator iter;


thank you, works perfectly now.

Topic archived. No new replies allowed.