Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Ten plik zawiera funkcję „main”. W nim rozpoczyna się i kończy wykonywanie programu.
  2. //
  3.  
  4. #include <iostream>
  5. #include <string>;
  6.  
  7. using namespace std;
  8. class Human {
  9.  
  10. public:
  11.     string name;
  12.     int age;
  13.     virtual void im() {};
  14. };
  15. class Child : public Human {
  16. public:
  17.  
  18.     void im() {
  19.         cout << "Jestem dzieckiem. Moje imie to " << name << " Wiek to " << age << endl;
  20.     }
  21. };
  22. class Daddy : public Human {
  23. public:
  24.     void im() {
  25.         cout << "Jestem dorosłym. Moje imie to " << name << " Wiek to " << age << endl;
  26.     }
  27. };
  28. int main()
  29. {
  30.     Child c;
  31.     c.age = 15;
  32.     c.name = "Tomek";
  33.     c.im();
  34.     Daddy d;
  35.     d.age = 30;
  36.     d.name = "Mariusz";
  37.     d.im();
  38.    
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement