Advertisement
Carnby1021

Untitled

May 21st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<typename trik>
  6.  
  7. trik Dodaj(trik liczba,trik liczba1){
  8. return liczba+liczba1;
  9. }
  10.  
  11. template<typename T>
  12.  
  13. class Punkt{
  14. T x;
  15. T y;
  16. public:
  17. Punkt(T xx,T yy){
  18. this->x=xx;
  19. this->y=yy;
  20. }
  21. void Drukuj();
  22. };
  23. template<typename M>
  24.  
  25. void Punkt<M>::Drukuj(){
  26. cout<<"x="<<x<<" y="<<y<<endl;
  27. }
  28. int main(){
  29. int x=5,y=4,wynik;
  30. double a=1.7,b=1.4,wynik1;
  31.  
  32. wynik=Dodaj(x,y);
  33. wynik1=Dodaj(a,b);
  34.  
  35. cout<<wynik<<endl;
  36. cout<<wynik1<<endl;
  37.  
  38. Punkt<int> trik(3,4);
  39. trik.Drukuj();
  40. Punkt<double> triczek(3.8,7.1);
  41. triczek.Drukuj();
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement