简单c++

#include <iosteam>
using  std::string;

template<typename T1, typename T2>
class test
{
 private:
  T1 a;
  T2 b;
 public:
  //virtual int getNumber(char c)=0;
  test(T1 x, T2 y) //构造函数
  {
   a=x;
   b=y;
   }
  ~test()
  {
   cout<<"class test destructor function." << endl;
   }
   
  void print()//内联函数
  {
   cout << "a="<<a<<"b="<<b<<endl;
   }
   
}

int main(int argc, char* argv[])
{
 test<int,int> obj(5,10);
 obj.print();
 
 test<double,int> obj2(5.2,10);
 obj2.print();
 
 test<int,int> obj2(5.2,10);
 obj2.print();
 }

posted @ 2013-08-05 21:10  反光镜的博客  阅读(152)  评论(0)    收藏  举报