Hi I am doing an assignment and my professor gave us the code for a copy function for a doubly linked list. The function should copy list into another empty list and if the list being copied is empty it should just return and exit. Here is the code my prof gave me that is giving me a seg fault and I have no idea what is wrong. Any help is appreciated.
void Dll11List::copy(const Dll11List & orig){
if(!isEmpty()){
cerr<<"\nCalling DLL is not empty";
return;
}
if(orig.isEmpty()){
return;
}
Dll11Node *iterorig = orig._first;
_first = new Dll11Node(iterorig->_data);
Dll11Node *iterhere = _first;
while(iterorig->_fore != NULL){
iterorig = iterorig->_fore;
iterhere->_fore->_back = iterhere;
iterhere = iterhere->_fore;
}
_last = iterhere;
_size = orig.getSize();
}
thanks