반응형
visual stdio 2017 ][ auto keyword
■ auto keyword
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
// cl.exe /analyze /EHsc /W4 | |
#include <iostream> | |
#include <vector> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
int count = 10; | |
int& countRef = count; | |
auto myAuto = countRef; | |
countRef = 11; | |
cout << count << " "; | |
myAuto = 12; | |
cout << count << endl; | |
vector<string> vecStr; | |
vecStr.push_back("aa"); | |
vecStr.push_back("bb"); | |
vecStr.push_back("cc"); | |
vector<string>::iterator itVec = vecStr.begin(); | |
auto it = vecStr.begin(); | |
for (vector<string>::iterator i = it; it != vecStr.end(); it ++ ) | |
{ | |
cout << *it << endl; | |
} | |
} |
반응형