Advertisement
Kocyk

zwierzetaklasy

Oct 25th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class zwierze{
  5. private:
  6.     string imie;
  7.  
  8.  
  9. public:
  10.     static int licznik;
  11.     zwierze(string imie_k)
  12.     {
  13.         imie=imie_k;
  14.         licznik++ ;
  15.     }
  16.    void ustawImie(string imie_new)
  17.     {
  18.         imie=imie_new;
  19.     }
  20.     string naLancuch ()
  21.     {
  22.         string &ref=imie;
  23.         return ref;
  24.     }
  25.     static int ileZwierzat()
  26.     {
  27.         return licznik;
  28.     }
  29. };
  30. int zwierze::licznik=0;
  31. bool porownaj(zwierze z1,zwierze z2)
  32. {
  33.     if(z1.naLancuch() == z2.naLancuch()) return true;
  34.         else return false;
  35. }
  36. int main()
  37. {
  38.   zwierze z3("Endrju");
  39.   zwierze z1("Kasztan");
  40.   zwierze z2("Spawymir");
  41.   z1.ustawImie("Spawymir");
  42.   cout<< z1.naLancuch()<<endl;
  43.   cout<< z2.naLancuch()<<endl;
  44.   cout<< porownaj(z1,z2)<<endl;
  45.   cout<< zwierze::ileZwierzat() <<endl;
  46.   return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement