Lecture 8 Flashcards
Vector
Collection of some number of variables. Address the problems with arrays
Generic Programming
Allows a general algorithm to be written that works for all data types. Increases efficiency.
Template
A formula for creating a generic class or function
Class
User defined data type
Push_back
Member function that adds a new element to the end of a vector
Member function
A function that can operate on any object of a the class which it is defined in.
Vector declaration
Vector<type> name;
Or
Vector<type> name(size);
Or
Vector<type> name(size, initial value of all elements)</type></type></type>
Vector initialization
Vector<type> name = {element, element...}
Or
name = {element, ...}</type>
Options to initalize size
- Initialize in parentheses
- Initialize elements and size will automatically initialize
- Initialize in parentheses with starting values
Size function
Function to find the size of a vector.
Data structure
A group of data elements grouped together under one name.
An organized way to store a collection of data: e.g. Array, vector, etc.