-
Weird Destructor Error
I get a weeeird error when defining my destructor, it uses another function Purge() to accomplish the job..
Code:
template <class T> // LinkedList Member Function, cleans up List Elements, Purges them
void LinkedList<T>::Purge()
{
while (head != 0)
{
ListElement<T>* const tmp = head;
head = head->next;
delete tmp;
}
tail = 0;
}
template <class T> // Destructor, uses purge!
void LinkedList<T>::~LinkedList()
{ Purge (); }
Here is the error..
Code:
c:\documents and settings\jonathan\my documents\c++ programming\opengl with nehe\nehe tutorials\tutorials databasing\single_linked_list.h(82) : error C2631: 'LinkedList<T>::~LinkedList<T>' : destructors not allowed a return type
What do I do?
-
Teehee, can't void the destructor :D
-
just as an aside, you might want to look at boost::ptr_vector for this kind of "container of new'd objects". it'll make your life easier