Hello, I'm new to iterators in C++ and I'm facing problem with incompatible iterators. I've spent on this over 7 hours and still I can't figure out why it's not compatible or what I did wrong. I'm sure, I messed up iterator's operators or something close to it. Could you please help me?
Iterator header
1 2 3 4 5 6 7 8 9 10 11
class iterator : public std::iterator < std::input_iterator_tag, Agent > {
list<Agent> agentList;
list<Agent>::iterator it;
public:
iterator(list<Agent>** env, int rows, int cols);
voidoperator ++(int);
booloperator ==(const iterator& a) const;
booloperator !=(iterator& a) const;
Agent& operator*();
void setEnd();
};
If your compiler doesn't complain about this, it might be time to get a new compiler.
Your iterator does not properly define a copy constructor or copy assignment operator, both of which will be required if you wish to to continue with the queer notion that an iterator should own its list.