C - C++ Templates - Class Template

#include<iostream>
using namespace std;
 
template<class R>
class test
{
  R data;
 
public:
  void getdata();
  void putdata();
};
 
 
template<class R>
void test<R>::getdata()
{
  cout<<"Enter data";
  cin>>data;
}
 
 
template<class R>
void test<R>::putdata()
{
  cout<<"Data is"<<data<<endl;
}
 
 
int main()
{
  test<int>t1;
  test<double>t2;
  t1.getdata();
  t1.putdata();
  t2.getdata();
  t2.putdata();
 
  return 0;
}