• Source
    1. #include <iostream>
    2. #include <vector>
    3. using namespace std;
    4.  
    5. class TestClass {
    6. public:
    7. TestClass() {}
    8. };
    9.  
    10. int main() {
    11. // コンパイラが型を推論してくれるので長いクラス名書かなくていい。
    12. auto test = new TestClass();
    13.  
    14. vector<string> strs {
    15. "one",
    16. "two",
    17. "three"
    18. };
    19.  
    20. // 型名が長くなりがちなIterator関係もスッキリ
    21. // (とはいえ range based for を使う方がスッキリする)
    22. for (auto it = strs.begin(); it != strs.end(); it++) {
    23. cout << *it << endl;
    24. }
    25.  
    26. delete test;
    27.  
    28. return 0;
    29. }