Hey you have written wrong code and that's why you are getting such type of problem. I have written following code for you. It is working program. In the following code I have use ~CLists() to define destructor. I also have use pPointers = pRoots; to sets the pointer to start at the beginning of the list.
Code:
CLists::~CLists() // destructor
{
CNode *pPointers;
pPointers = pRoots;
do
{
CNodes *pPointersDels;
pPointersDels = pPointers;
delete pPointerDels;
if(pPointers->pNexts != 0)
{
pPointers = pPointers->pNexts;
}
} while(pPointers != pHead);
}
Bookmarks