CMPSC 16 Lecture Notes - Lecture 15: Random Number Generation, Generic Function, Dynamic Array

43 views3 pages
7 Dec 2018
School
Course
Professor

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)

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents