Advertisement
Guest User

vector2

a guest
May 26th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. //Bartłomiej Błazik
  2. #pragma once
  3. #include "Vector.h"
  4. #include <string>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. //PrintVector
  10. template <typename T>
  11. void printVector(const Vector<T>& v, std::string id)
  12. {
  13.     if (v.empty())
  14.         cout << "Vector " << id << " jest pusty.\n\n";
  15.     else
  16.     {
  17.         cout << id << ": { ";
  18.         for (typename Vector<T>::size_type i = 0; i < v.size(); i++)
  19.         {
  20.             cout << v[i] << "; ";
  21.  
  22.         }
  23.         cout << "Capacity: " << v.capacity();
  24.         cout << "}\n\n";
  25.     }
  26. }
  27. //PrintVector - koniec
  28.  
  29. int main()
  30. {
  31.    
  32.     Vector<int,std::allocator<int>> v1;
  33.     Vector<int, std::allocator<int>> v2(5);
  34.  
  35.    
  36.     printVector(v1, "v1");
  37.     printVector(v2, "v2");
  38.     /*
  39.     v1[1] = 1;
  40.  
  41.     v1.reserve(6);
  42.     printVector(v1, "v1 after reserve 6");
  43.  
  44.  
  45.     v2.resize(6);
  46.     printVector(v2, "v2 after resize 6");
  47.  
  48.     //v2.push_back(3);
  49.     //printVector(v2, "v2 after pushback");
  50.     */
  51.     cout <<
  52.         system("pause");
  53.        
  54. }
  55.  
  56.  
  57.  
  58.  
  59. #include "Vector.cpp"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement