#include <iostream>
using namespace std;
template <class T>
class array {
public:
array(int s=10);
array(const array &rhs);
~array() { delete [] type; --num;}
array& operator=(const array&);
T& operator[](int offset) {return type[offset];}
const T& operator[](int offset) const
{return type[offset];}
int itssize() { return size;}
template <T>
friend ostream& operator<<(ostream&,array<T>&);
//template <T>
static int getnum() {return num;}
private:
T *type;
int size;
static int num;
};
template <class T>
int array<T>::num = 0;
template <class T>
ostream & operator<<(ostream& output,array<T>& arrg) {
for(int i=0;i<arrg.itssize();i++)
output<<arrg[i]<<endl;
return output;
}
template <class T>
array<T>::array(int s):size(s) {
type = new T[size];
for(int i=0;i<size;i++)
type[i] = (T)0;
num++;
}
template <class T>
array<T>::array(const array & rhs) {
int s = rhs.itssize();
type = new T[s];
for(int i =0 ;i<s;i++)
type[i] = rhs[i];
num++;
}
template <class T>
array<T> & array<T>::operator=(const array &rhs) {
if(this == &rhs)
return *this;
delete [] type;
int s = rhs.itssize();
type = new T[s];
for(int i=0;i<size;i++)
type[i] = rhs[i];
return *this;
}
int main()
{
cout<<array<int>::getnum()<<endl;
cout<<array<float>::getnum()<<endl;
array<int> that;
array<float> athat;
cout<<that.getnum()<<endl;
cout<<athat.getnum()<<endl;
array<int>* p=new array<int>;
cout<<that.getnum()<<endl;
cout<<athat.getnum()<<endl;
delete p;
cout<<that.getnum()<<endl;
cout<<athat.getnum()<<endl;
return 0;
}