Created
January 12, 2014 01:34
-
-
Save pasberth/8379449 to your computer and use it in GitHub Desktop.
すべての要素を出力する
This file contains hidden or 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
| #include <string> | |
| #include <vector> | |
| #include <list> | |
| #include <iostream> | |
| template<class Iterator> | |
| void print_all(Iterator first, Iterator last) | |
| { | |
| while (first != last) | |
| { | |
| std::cout << *first << std::endl; | |
| ++first; | |
| } | |
| } | |
| int main(int argc, char const *argv[]) | |
| { | |
| std::vector<std::string> v; | |
| v.push_back("a"); | |
| v.push_back("b"); | |
| v.push_back("c"); | |
| print_all(v.begin(), v.end()); | |
| std::list<std::string> l; | |
| l.push_back("a"); | |
| l.push_back("b"); | |
| l.push_back("c"); | |
| print_all(l.begin(), l.end()); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment