#include <iostream>
using namespace std;
template<class T> class tcontainer
{
virtual void push(const T& );
virtual const T& pop();
virtual const T& begin();
virtual const T& end();
virtual size_t size();
};
template<class T> class tvector : public tcontainer<T>
{
public:
tvector(){_cap=100;_size=0;buf=new T[_cap];}
~tvector(){delete [] buf;}
void push(const T& v)
{
if (_size=_cap)
{
T* nbuf=new T[_cap*2];
for(size_t i=0;i < _size-1;i++)
nbuf[i]=buf[i];
delete buf;
buf=nbuf;
nbuf=0; }
buf[_size++]=v;
}
const T& pob()
{
return buf[--_size];
}
const T& begin()
{
return buf[0];
}
const T& end()
{
return buf[_size-1];
}
size_t size()
{
return _size;
}
const T & operator[](size_t i)
{
return buf[i];
}
private:
size_t _size;
size_t _cap;
T *buf;
};
int main()
{
tvector<int> v;
for (int i=0;i<10;i++)
{
v.push(i);
}
for (int i=0;i<10;i++)
{
cout<<v[i]<<endl;
}
return 0;
}