Josif_tepe

Untitled

Jul 10th, 2025
625
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.  
  4. class Animal {
  5. private:
  6.     string tip;
  7.     string ime;
  8.     bool masko;
  9. public:
  10.     Animal() {}
  11.     Animal(string _tip, string _ime, bool _masko) {
  12.         tip = _tip;
  13.         ime = _ime;
  14.         masko = _masko;
  15.     }
  16.     Animal(const Animal & tmp) {
  17.         tip = tmp.tip;
  18.         ime = tmp.ime;
  19.         masko = tmp.masko;
  20.     }
  21.    
  22.     void print() {
  23.         cout << tip << " " << ime << " " << masko << endl;
  24.     }
  25. };
  26.  
  27. class Cat : public Animal {
  28. private:
  29.     string rasa;
  30.     int godini;
  31. public:
  32.     Cat() : Animal() {
  33.        
  34.     }
  35.    
  36.     Cat(string _tip, string _ime, bool _masko, string _rasa, int _godini) : Animal(_tip, _ime, _masko) {
  37.         rasa = _rasa;
  38.         godini = _godini;
  39.     }
  40.    
  41.     Cat(const Cat & tmp) : Animal(tmp) {
  42.         rasa = tmp.rasa;
  43.         godini = tmp.godini;
  44.     }
  45.    
  46.     void pechati() {
  47.         Animal::print();
  48.         cout << rasa << " " << godini << endl;
  49.     }
  50. };
  51.  
  52. int main() {
  53.    
  54.     Cat c("cat", "Mila", false, "british shorthair", 1);
  55.    
  56.     c.pechati();
  57.     return 0;
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment