I have a List class that has nodes of type Node.
class List{
Node* head;
int size;
public:
List();
List(const Team&, Node* = NULL);
List& operator=(const List&);
~List();
int getSize() const;
void setSize(int);
Node* getHead() const;
void setHead(Node*);
};
class Node{
Team value;
Node* next;
public:
Node(const Team& = Team(), Node* = NULL);
Team getValue() const;
void setValue(const Team&);
Node* getNext() const;
void setNext(Node*);
};
The destructor for my List class works fine and empties the list. Should I also have a destructor for my Node class?
List::~List(){
while(head != NULL){
Node *temp = head->getNext();
delete head;
head = temp;
size--;
}
}