shizaero

Универсальные функции вывода контейнеров / Задание № 1

Jan 11th, 2023
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     for (const auto& element : container) {
  9.         out << element << " "s;
  10.     }
  11.     return out;
  12. }
  13.  
  14. int main() {
  15.     const vector<int> ages = {10, 5, 2, 12};
  16.     cout << ages << endl;
  17. }
Add Comment
Please, Sign In to add comment