#include<iostream.h>
 template <class T>
 class counter
{
 public:
  counter(T number);//构造函数
  counter(counter &p);//拷贝构造函数
  ~counter( );//析构函数
  void increment( );//计数器加1
  void decrement( );//计数器减1
  T get_v(void);//取得计数器的值
  void show_v(void);//显示计数器的值
 private:
  T value;
};
 template <class T>
 counter<T>::counter(T number)
{
 value=number;
 cout<<"计数器创建"<<endl;
}
 template <class T>
 counter<T>::counter(counter &p)
{
 value=p.value; 
 cout<<"计数器创建"<<endl;
}
 template <class T>
 counter<T>::~counter( )
{
 cout<<"计数器消亡"<<endl;
}
 template <class T>
 void counter<T>::increment( )
{
 value++;
}
 template <class T>
 void counter<T>::decrement( )
{
 value--;
}
 template <class T>
 T counter<T>::get_v(void)
{
 return(value);
}
 template <class T>
 void counter<T>::show_v(void)
{
 cout<<"value="<<value<<endl;
}
 int main()
{
 counter<int> t1(1),t2(t1);
 t1.show_v();
 cout<<"value="<<t2.get_v()<<endl;
 t1.increment();
 t2.decrement();
 t1.show_v();
 t2.show_v(); 
 return(0);
}