My question is how can I access an iterator that is a private member of a class?
Code:
class Sequence
{
friend ostream& operator<<(ostream& OUTPUT, const Sequence & s);
public:
...
private:
list <int> intList;
list <int> :: iterator ListIt;
}
...
ostream& operator<<(ostream& OUTPUT, const Sequence& s)
{
for(ListIt=s.intList.begin(); ListIt != intList.end(); ListIt++)
{
cout << *ListIt;
}
return OUTPUT;
}
I have tried the above, and several other ways and I keep getting a compilier error that ListIt is undeclared. Thanks.