i just want to know how to write a circular linked list destructor. anybody help?

Recommended Answers

All 3 Replies

class List
{
public:
   ~List(); // destructor
};
commented: Hehe. +3

i just want to know how to write a circular linked list destructor. anybody help?

The same way you'd write any destructor. What's so hard about the circular linked list case?

Just destroy all of the nodes.

Do you know how to write one for a terminated list? It's not all that bad. At the root just set the 'previous' to NULL, and set previous->next to NULL and go through it until you reach NULL.
Alternatively you could use auto_ptrs or something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.