Skip to content

Instantly share code, notes, and snippets.

@vbuterin2
Created September 24, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbuterin2/381e1c07a02704cd4812ee71646a0c1d to your computer and use it in GitHub Desktop.
Save vbuterin2/381e1c07a02704cd4812ee71646a0c1d to your computer and use it in GitHub Desktop.
// vector::push_back
#include <iostream>
#include <vector>
int main()
{
vector<int> v1;
const vector<int> v2;
// begin() function is used to return an iterator pointing to the first element of the vector container.
auto it1 = v1.begin(), it2 = v2.begin();
// cbegin will return a const_iterator unconditionally. begin() returns the iterator to beginning while cbegin() returns const_iterator to beginning.
auto it3 = v1.cbegin(), it4 = v2.cbegin();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment