I have a vector of Linked list pointers.
Each LinkedList has a head pointer which is a pointer to a Node. That node of course is the head of the list.
The head of vector[3] is the same as the head of vector[0].
I change the head pointer of vector[0] to point to the same node that vector[1] points to, or the head of vector[1].
However the head pointer of vector[3] never changes. How can I get it so that by changing the head pointer of vector[0] I can also change the head pointer of vector[3] as well?
I have tried 2 different methods. None have worked.
vector[0]->head=vector[1]->head;
*(vector[0]->head)=*(vector[1]->head);
You cannot change two values with a single assignment.
In your case there is
vector[0]->headandvector[1]->head, two different pointers with two values. They will only be equal as long as you keep them so, by changing one when you change the other.You could use an additional level of indirection:
Though this does not smell like good design.