Advertisement
AnaGocevska

Zhivotni

Apr 26th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Zhivotno
  6. {
  7. protected:
  8.     string ime;
  9. public:
  10.     Zhivotno(string ime="")
  11.     {
  12.         this->ime=ime;
  13.     }
  14.  
  15. };
  16.  
  17. class Kopneni:public Zhivotno
  18. {
  19. protected:
  20.     bool krzno;
  21.     string hrana;
  22. public:
  23.     Kopneni(string ime="", bool krzno=false, string hrana=""):Zhivotno(ime)
  24.     {
  25.         this->krzno=krzno;
  26.         this->hrana=hrana;
  27.     }
  28. };
  29.  
  30. class Lav:public Kopneni
  31. {
  32. protected:
  33.     bool div;
  34. public:
  35.     Lav(string ime="", bool krzno=false, string hrana="", bool div=false):Kopneni(ime, krzno, hrana)
  36.     {
  37.         this->div=div;
  38.     }
  39.  
  40.     void pecati()
  41.     {
  42.         cout<<"Ime: "<<ime<<endl;
  43.         cout<<"Krzno: "<<krzno<<endl;
  44.         cout<<"Tip hrana: "<<hrana<<endl;
  45.         cout<<"Dali e div? "<<div<<endl;
  46.     }
  47. };
  48.  
  49. class Slon:public Kopneni
  50. {
  51. protected:
  52.     char *poteklo;
  53. public:
  54.     Slon(string ime="", bool krzno=false, string hrana="", char *poteklo=""):Kopneni(ime, krzno, hrana)
  55.     {
  56.         strcpy(this->poteklo, poteklo);
  57.     }
  58. };
  59.  
  60. class Vodeni:public Zhivotno
  61. {
  62. protected:
  63.     string dishenje;
  64. public:
  65.     Vodeni(string dishenje="")
  66.     {
  67.         this->dishenje=dishenje;
  68.     }
  69. };
  70.  
  71. class Jagula:public Vodeni
  72. {
  73. protected:
  74.     int jachinaElPolnezh;
  75. public:
  76.     Jagula(string dishenje="", int jachinaElPolnezh=0):Vodeni(dishenje)
  77.     {
  78.         this->jachinaElPolnezh=jachinaElPolnezh;
  79.     }
  80. };
  81.  
  82. class Delfin:public Vodeni
  83. {
  84. protected:
  85.     bool cirkus;
  86. private:
  87.     Delfin(string dishenje="", bool cirkus=false):Vodeni(dishenje)
  88.     {
  89.         this->cirkus=cirkus;
  90.     }
  91. };
  92. int main()
  93. {
  94.     Lav l("Leo", true, "mesojad", false);
  95.     l.pecati();
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement