I am in the process of creating my own linked list. I am attempting to create an overloaded constructor of my linked list that takes two node_iterators that point to the head and tail of another linked list.
overloaded list constructor:
template <typename T>
list<T>::list(node_iterator<T> front, node_iterator<T> back)
{
unsigned temp;
this->head = front.get_current();
while(front != back)
{
++temp;
++front;
}
this->tail = back.get_current();
this->used = temp;
}
Above head and tail are node<T>* to my nodes in the list. front and back node_iterators that I have created. The get_current() method returns a node<T>* to the current node my node_iterator class is pointing at. I have tested my overloaded ++ and != operator in my node_iterator class and they work. However when attempt to create my list class with the above constructor I get the following error:
*** glibc detected *** ./a.out: munmap_chunk(): invalid pointer: 0xbf91b1a4 ***
Any tips on how I can fix this or do the above in a better fashion? Please let me know if you need to see more.
tempis never initialised.tempis uninitialized (it's not the crasher - at least not here).