Last active
September 26, 2018 03:23
-
-
Save abranhe/317d6991dd54217ddd77241c678315d2 to your computer and use it in GitHub Desktop.
Auto example in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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