How do Iterators work on a List in C++? -
this confusion have how iterators work on list in c++. please correct me if wrong.
a list (in c++) under hood double linked list. know structure of doubly linked list-a data area , pointer next , previous nodes. every node in doubly linked list has address in memory. when declare iterator on on list, points address. when derefence iterator, how data value?
the iterator's dereference operator defined return (a reference to) value contained in node. example defined this:
template<t> t& list<t>::iterator::operator *() { return this->node_pointer->value; }
Comments
Post a Comment