- What is a container?
A Container is an object that holds other objects
- What is an iterator?
Iterator is a means of traversing objects in the container (Used to navigate containers)
- Important member of a Container for iterator
iterator begin() //points to the first element
const_iterator begin() const
iterator end() //points to one-past-last element
const_iterator end() const
reverse_iterator rbegin()
const_reverse_iterator ebegin() const;
reverse_iterator end()
const_reverse_iterator rend() const;
- Element access in a vector
reference operator[] (size_type n); //unchecked access
reference at (size_type n); //checked access
- Passing vectors
f1(vector
f2(const vector
vector
f1(v) //pass reference
- reserve in vector allocates space in advance
- capacity() gives the current numbers of reserved memory slots
- size() gives the current number of elements
- Pointer cannot address a unit of memory smaller than a byte
- Link
Vector Code
No comments:
Post a Comment