Kocyk

dunno qt jakies ale jednak nie

Jan 17th, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class pies
  5. {
  6.   public:
  7.     string wyswietl()
  8.     {
  9.         return "Pies";
  10.     }
  11. };
  12. class kot
  13. {
  14.   public:
  15.     string wyswielt()
  16.     {
  17.         return "Kot";
  18.     }
  19. };
  20. template <typename B,int pojemnosc>
  21. class buda
  22. {
  23.   B *wsk[pojemnosc];
  24. public:
  25.   B *get(int indeks)
  26.   {
  27.      return wsk[indeks];
  28.   }
  29.   B set(B wartosc,int indeks)
  30.   {
  31.       *wsk[indeks]=wartosc;
  32.   }
  33. };
  34. int main(int argc, char *argv[])
  35. {
  36.  
  37.  
  38.     kot czesiek;
  39.     pies papito;
  40.  
  41.     buda<pies,1> psia;
  42.     buda<kot,2> kocia;
  43.  
  44.     psia.set(papito,1);
  45.     kocia.set(czesiek,1);
  46.  
  47.     cout<<psia.get(1)->wyswietl()<<endl;
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment