Iterator pointer question

I'm so confused right now. Why does my iterator (*it) = _NODE[ListPOS
crashes.

Can someone explain what it does and why it crashes?

Also, _NODE is a vector.

it is an iterator std::vector<Node*>::iterator it;

& ListPOS is an iterator to access the position in the vector. I'm creating a directed graph with vectors. Thanks

1
2
3
4
  void Node::AddNode(unsigned int ListPOS ,unsigned int NodePos, unsigned int _Getweight){
   
    (*it) = _NODE[ListPOS];
    
There are several possibilities.

it could be uninitialized, invalidated, or refer to end().

ListPOS could be greater than or equal to _NODE.size().
Last edited on
Topic archived. No new replies allowed.