CS 111 (Chapter 10)
True/False: A vector object automatically expands in size to accommodate the items stored in it
True
This vector function returns the number of elements in a vector
size
This vector function removes an item from a vector
pop_back
What will the following C++ 11 code display? vector<int> numbers { 3,5 }; for (int val: numbers) cout << val << endl;
3 5
What does the following statement do? vector<int> v(10, 2);
It creates a vector object with a starting size of 10 and all elements are initialized with the value 2
This vector function returns true if the vector has no elements
empty
What does the following statement do? vector<int>v(10);
it creates a vector object with a starting size of 10
This vector function is used to insert an item into a vector
push_back
Which statement correctly uses C++ 11 to initialize a vector of ints named n with the values 10 and 20?
vector<int>n{ 10,20 };
Which statement correctly defines a vector object for holding integers?
vector<int>v;