Okay, I'm trying to have a linked list autonomously delete itself, however, the destructor function I am using doesn't seem to work, it just keeps constantly looping, until the program just ends itself.
Here's the function:
node::~node()
{
if(this->next != NULL){delete this->next;}
delete this;
}
Basically, this should run through the linked list, activating each ones destructor until the last one, then they will all delete themselves from the back up.
Now, I know that the more orthodox method is to have two pointers, one to delete and one as a temporary pointer to the next node, however, this seems like a better method that uses less variables, does anyone know why it isn't working though?