Advertisement
chevengur

СПРИНТ № 2 | Шаблоны функции | Урок 5: Универсальные функции вывода контейнеров 1/6

Oct 26th, 2023 (edited)
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. template<typename type>
  7. ostream& operator<< (ostream& out, const vector<type>kunteynir){
  8.     for(const auto& kon: kunteynir){
  9.         out << kon << " ";
  10.     }
  11.  
  12.     return out;
  13. }
  14.  
  15. int main() {
  16.     const vector<int> ages = {10, 5, 2, 12};
  17.     cout << ages << endl;
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement