Advertisement
Josif_tepe

Untitled

Apr 27th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Zivotno {
  5. private:
  6.     char ime[50];
  7. public:
  8.     Zivotno() {
  9.        
  10.     }
  11.     Zivotno(char *c) {
  12.         strcpy(ime, c);
  13.     }
  14.     virtual void print_name() {
  15.         cout << "Zivotno: " << ime << endl;
  16.     }
  17.     void f(int x, int y) {
  18.         cout << x << " " << y << endl;
  19.     }
  20.     virtual ~Zivotno() {
  21.        
  22.     }
  23. };
  24. class Kuce : public Zivotno {
  25. private:
  26.     char rasa[50];
  27. public:
  28.     Kuce() {
  29.        
  30.     }
  31.     Kuce(char *ime, char *r) : Zivotno(ime) {
  32.         strcpy(rasa, r);
  33.     }
  34.     void print_name() override {
  35.         cout << "Rasa: " << rasa << endl;
  36.     }
  37.     void f(int x) {
  38.         cout << x << endl;
  39.     }
  40.     ~Kuce() {
  41.        
  42.     }
  43. };
  44. int main() {
  45.     Zivotno *z = new Kuce("kuce", "frenchie");
  46.     z->print_name();
  47.     return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement