CMPSC 16 Lecture Notes - Lecture 15: Random Number Generation, Generic Function, Dynamic Array
Document Summary
C++ memory model: text (read-only), bss (global and static variables), stack, heap. Memory management and creating on the heap so that the data is still there even when the function returns. Stl: know the basic usage of vectors and arrays but no generic function writing and templates. Vectors: how to add, initialize, and access. Just know the basic functions of the string library and how to use them (in the ppt) Static variables: one copy that can be defined inside of a function (not recreated each time the function is called) Vector: dynamically sized array (can start w/ no elements) Syntax: vector v1; //int is the type that can be stored in it. V1. push_back(): adds an element to the end of the vector. V1 is on the stack, but it points to a dynamic array on the heap (stores the new length each time a new element is added)