Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #ifndef__MyVector_H
  2. #define__MyVector_H
  3.  
  4. using namespace std;
  5.  
  6. template<typename T>
  7. class MyVector
  8. {
  9.         int size;
  10.         int capacity;
  11.         int v;
  12.        
  13.     public:
  14.      MyVector()
  15.      {
  16.          size=0;
  17.          capacity=10;
  18.          v=new T[10];
  19.      }
  20.     ~MyVector();
  21.     void add(T element)
  22.     {
  23.         if(size < capacity)
  24.         {
  25.             v[size]=element;
  26.             size=size+1;
  27.         }
  28.         else
  29.         {
  30.             T new_vector=new T[2*capacity];
  31.             capacity=capacity*2;
  32.             for(i=0;i<size;i++)
  33.             {
  34.                 new_vector=v;
  35.                 cin>>x;
  36.                 v[i]=x;
  37.                 i++;
  38.             }
  39.         }
  40.     }
  41.  
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement