is Recursion ok in a deconstructor?
I was wonder if any problems might come up from using recursion in a properly coded deconstructor for a single linked list.
Code:
class MyList
{
ListData* pListData;
MyList* pNextNode;
}
MyList::~MyList()
{
if (pListData)
delete pListData;
if (pNextNode)
delete pNextNode;
}
ListData has it's own deconstructor that deletes whatever it needs to. Testing it with a cout seems to show it being called the correct number of times. Also, should I set pNextNode to NULL inside the deconstructor?