SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | #include <vector> | |
| 3 | ||
| 4 | using namespace std; | |
| 5 | ||
| 6 | template <typename Element> | |
| 7 | ostream& operator<<(ostream& out, const vector<Element>& container) {
| |
| 8 | bool is_first = true; | |
| 9 | for (const auto& element : container) {
| |
| 10 | if (!is_first) {
| |
| 11 | out << ", "s; | |
| 12 | } | |
| 13 | is_first = false; | |
| 14 | out << element; | |
| 15 | } | |
| 16 | return out; | |
| 17 | } | |
| 18 | ||
| 19 | int main() {
| |
| 20 | const vector<int> ages = {10, 5, 2, 12};
| |
| 21 | cout << ages << endl; | |
| 22 | } |