andrelievable

zad 3

Nov 23rd, 2020 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <stdexcept>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. template<typename T1, typename T2, typename T3>
  10. class Triple
  11. {
  12. public:
  13.     T1 a;
  14.     T2 b;
  15.     T3 c;
  16.  
  17.     ~Triple()
  18.     {
  19.         cout << "wywolujemy destruktor" << endl;
  20.     }
  21.  
  22.     Triple(T1 one, T2 two, T3 three)
  23.     {
  24.         this->a = one;
  25.         this->b = two;
  26.         this->c = three;
  27.  
  28.     }
  29.  
  30.     void one()
  31.     {
  32.         cout << "piewrszy el: " << this->a << endl;
  33.     }
  34.  
  35.     void two()
  36.     {
  37.         cout << "drugi el: " << this->b << endl;
  38.     }
  39.    
  40.     void three()
  41.     {
  42.         cout << "trzeci el: " << this->c << endl;
  43.     }
  44. };
  45.  
  46.  
  47.  
  48. int main()
  49. {
  50.     int x = 5;
  51.     char y = 'a';
  52.     double z = 1.8;
  53.     Triple <int, char, double> obj(x, y, z);
  54.     obj.one();
  55.     obj.two();
  56.     obj.three();
  57.  
  58.     return 0;
  59. }
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment