Skip to content

Instantly share code, notes, and snippets.

@abranhe
Last active September 26, 2018 03:23
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 abranhe/317d6991dd54217ddd77241c678315d2 to your computer and use it in GitHub Desktop.
Save abranhe/317d6991dd54217ddd77241c678315d2 to your computer and use it in GitHub Desktop.
Auto example in C++
// Author: Abraham (@abranhe)
// Run it: https://repl.it/@abranhe/AutoExample
// C++ 11 or later
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> v = {0,1 ,2 ,3 ,4};
cout << "Simple Way: " << endl;
for(auto item:v)
{
cout << item << endl;
}
cout << "Complex Way: " << endl;
for(auto i = begin(v); i != end(v); i++)
{
cout << *i << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment