fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // Клас Серце
  5. class Heart {
  6. public:
  7. void beat() {
  8. cout << "Серце б'ється ❤️" << endl;
  9. }
  10. };
  11.  
  12. // Клас Людина (має серце)
  13. class Human {
  14. private:
  15. Heart heart; // композиція: Людина МАЄ Серце
  16.  
  17. public:
  18. void live() {
  19. cout << "Людина живе" << endl;
  20. heart.beat();
  21. }
  22. };
  23.  
  24. int main() {
  25. Human person;
  26. person.live();
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Людина живе
Серце б'ється ❤️