Errr, I'm getting a seg fault when I call the copy ctor like this:
Code:
List<int> m_list2( m_list );
That's with or without the use of clear() in the copy ctor:
Code:
template <typename T>
List<T>::List(const List& rhs_l) : head(0), tail(0), sizeOfList(0){
//clear();
for(Iter i(rhs_l.head); i != end(); i++){
push_back(*i);
}
}
should head and tail be initialized in some other way?
lf I change the constructor to this:
Code:
template <typename T>
List<T>::List(const List& rhs_l) : sizeOfList(0){
head = tail = new Node(NULL);
for(Iter i(rhs_l.head); i != end(); i++){
push_back(*i);
}
}
I don't get the seg fault but of course now I have an erroneous node in the list that I don't want.
What's gong on here?