Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class zwierze
  4. {
  5. public:
  6.     string imie;
  7.     int ilosc_nog;
  8.     static int id;
  9. };
  10. class Zyrafa : public zwierze
  11. {
  12.     public:
  13.     void dodaj_zyrafe()
  14.     {
  15.            for(int i=0;i<5;i++)
  16. {
  17.  
  18.        cout<<"Podaj imie zyrafy "<<" : ";
  19.         cin>>imie;
  20.         cout<<"Ilosc nog: ";
  21.         cin>>ilosc_nog;
  22.         cout<<"ID Zyrafy "<<id<<endl;
  23.         id++;
  24.  
  25. }
  26.     }
  27.     void glos()
  28.     {
  29.         cout<<"glos zyrafy  "<<endl;
  30.     }
  31. };
  32.  
  33. class Slon : public zwierze
  34. {
  35.     public:
  36.     void dodaj_slonia()
  37.     {
  38.  
  39.               for(int i=0;i<5;i++)
  40. {
  41.         cout<<"Podaj imie slonia "<<" : "<<endl;
  42.         cin>>imie;
  43.         cout<<"Ilosc nog: ";
  44.         cin>>ilosc_nog;
  45.         cout<<"ID Slon "<<id<<endl;
  46.         id++;
  47.     }
  48.     }
  49.     void glos()
  50.     {
  51.         cout<<"glos slonia "<<endl;;
  52.     }
  53. };
  54. int zwierze::id = 0;
  55. int main()
  56. {
  57.  
  58.  
  59.     Zyrafa zyrafa;
  60.     zyrafa.dodaj_zyrafe();
  61.     zyrafa.glos();
  62.  
  63.     Slon slon;
  64.     slon.dodaj_slonia();
  65.     slon.glos();
  66.  
  67.     //na ocene 4//
  68.  
  69.  
  70.     //na 5//
  71.  
  72.  
  73.  
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement