CMPSC 32 Lecture Notes - Lecture 5: C Dynamic Memory Allocation, Iterator
Document Summary
Only way to change size is to copy the entire thing to a larger array. Whatever is contained in it is in angle brackets. Push things on to the end, or insert things into the middle. Syntax to add/remove/access/change things looks like array syntax. O(1) int i = v[5]; v[7] = 8; v is an lvalue. Pointers (in between way) int* x = new int[10]; v is an rvalue. Reading value on the right hand side of the equal side. Old way: int* x = (int *)malloc(10) malloc = memory allocation. Type cast x can be passed outside of scope. Heap = large amount of memory that gets written to / read. Moving around / changing pointers = garbage collection. Liveness of pointer variable is a global property. Plug in type parameters (not values, like in function calls) A type is plugged into dummy variable t. You write (almost) identical code in several places.