*EDIT* IT IS A SEGMENTATION FAULT NOT BUS ERROR (anyway to change thread title?)
I am trying to make a deep copy of a linked list, but whenever I run a test of the constructor i get a "Segmentation Fault". I tested the "Append" method and it works fine. I can't figure out why I am getting this error unless there is something wrong with "Append" though
Involved code:
Copy Contstructor:
List(const List &L){
ListIterator p;
p.currentPtr=L.head;
while(p.currentPtr->next!=L.head){
p.currentPtr=p.currentPtr->next;
this->Append(p.currentPtr->item);
listSize++;
}
} // copy constructor (*must* be a deep copy)
method Append:
void Append(int it){
ListIterator p;
p.currentPtr=this->head;
ListElement *temp= new ListElement();
temp->item=it;
if(this->IsEmpty()){
this->head->next=temp;
this->head->prev=temp;
temp->next=this->head;
temp->prev=this->head;
}
else{
temp->next=p.currentPtr;
temp->prev=p.currentPtr->prev;
p.currentPtr->prev->next=temp;
p.currentPtr->prev=temp;
p.currentPtr=temp;
}
listSize++;
}