c_-_c_templates:class_template
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; }
c_-_c_templates/class_template.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1