Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef__MyVector_H
- #define__MyVector_H
- using namespace std;
- template<typename T>
- class MyVector
- {
- int size;
- int capacity;
- int v;
- public:
- MyVector()
- {
- size=0;
- capacity=10;
- v=new T[10];
- }
- ~MyVector();
- void add(T element)
- {
- if(size < capacity)
- {
- v[size]=element;
- size=size+1;
- }
- else
- {
- T new_vector=new T[2*capacity];
- capacity=capacity*2;
- for(i=0;i<size;i++)
- {
- new_vector=v;
- cin>>x;
- v[i]=x;
- i++;
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement