CS 106B Lecture Notes - Lecture 17: Linked List, Memory Management
Document Summary
Logistics: thursday sections: not mandatory after noon. Feel free to find another to attend: midterm tomorrow evening, boggle: due on monday. Dynamic memory allocation: delete: after creating an array, when we delete it we do not delete the array. We just give back the memory and promise not to use it: you have a responsibility when using dynamic memory allocation to delete anything you have requested via new. We can fix this by adding a (cid:498)destructor(cid:499) (cid:523)~ before class(cid:524) When thee class instance goes out of scope, the destructor is called, cleaning up the memory for us (no need to call it manually) Vectorint class: implementation: has these properties. Can hold ints (holding other types is beyond scope of this class) Has useful functions: add(), insert(), get(), remove(), isempty(), size(), << overload. Can add as many elements as we like. Cleans up its own memory: code writing included in recording.