Computer Science 1037A/B Lecture Notes - Lecture 13: Elementis
Document Summary
Use push_back(value) add an element to a full vector or to a vector that had no defined size scores. push_back(75); Initialize undefined vector: vector hours; hours. push_back(10) hours. push_back(20) first element is 10 second element is 20. Not a member function vector a; reverse(begin(a),end(a)); at(position): returns the value of the element located at position in the vector x= vect. at(5); assigns the value of vect[5] to x. Use pop_back member function to remove last element from vector scores. pop_back(); To remove all contents of vector, use clear member function scores. clear(); To determine if vector is empty, use empty member function while(!scores. empty())