User Tools

Site Tools


c_-c_templates:class_template

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c_-c_templates:class_template [2017/10/12 11:29] – created peterc_-c_templates:class_template [2017/10/12 15:16] (current) – removed peter
Line 1: Line 1:
-====== C - C++ Templates - Class Template ====== 
- 
-<code cpp> 
-#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; 
-} 
-</code> 
  
c_-c_templates/class_template.1507807773.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki