Thread: Weird Destructor Error

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968

    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?
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  2. #2
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Teehee, can't void the destructor
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  3. #3
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    just as an aside, you might want to look at boost:tr_vector for this kind of "container of new'd objects". it'll make your life easier
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. weird
    By kiz in forum C Programming
    Replies: 8
    Last Post: 09-24-2007, 01:16 AM
  3. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  4. weird error
    By gandalf_bar in forum Linux Programming
    Replies: 2
    Last Post: 07-17-2005, 07:32 AM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM