Instance well keep initialise for other uses well

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ++ instance of our class. instance (We'll keep Initialise() for other uses.) (We'll Initialise() Applied Programming W e could then proceed to build our linked list We called Alist. 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. the Head W e have the complementary function to a We constructor – a destructor. destructor But what about space we may have dynamically But allocated? allocated? This is a public function called automatically when This 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 We want to clean up. Note that we don't have to clean up the memory Note for the instance itself. for Applied Programming A destructor's name is the name of the class destructor's preceded by a tilde ~ as in preceded ~LinkedList(); Applied Programming LinkedList::~LinkedList() { CustPtr tm...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online