Unformatted text preview: ++
instance of our class.
(We'll keep Initialise() for other uses.)
Initialise() Applied Programming W e could then proceed to build our linked list
Alist Applied Programming What happens when we leave the function? C++ helps out again. As Alist was automatic, C++ frees up space
As Alist was
allocated for it – the space for Head.
Head W e have the complementary function to a
constructor – a destructor.
destructor But what about space we may have dynamically
allocated? This is a public function called automatically when
a variable's space is freed up so that we can
clean up dynamic memory.
clean W e lose contact with it - a memory leak.
We want to clean up. Note that we don't have to clean up the memory
for the instance itself.
for Applied Programming A destructor's name is the name of the class
preceded by a tilde ~ as in
~LinkedList(); Applied Programming LinkedList::~LinkedList()
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14