Stupendous
[H]ard|Gawd
- Joined
- Aug 29, 2000
- Messages
- 1,370
Kinda new to C++ so I wanna see if this is right
A Node has a pointer to an item and the next node. For the destructor I just want to free the memory allocated for all the Nodes and not the data.
Is this correct?
A Node has a pointer to an item and the next node. For the destructor I just want to free the memory allocated for all the Nodes and not the data.
Is this correct?
Code:
class L
{
Node *head;
L::~L()
{
for(Node *c = head; c != NULL; c = c->next){
delete c;
}
}
};