Human.h 776 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #pragma once
  3. #include<iterator>
  4. #include <memory>
  5. #include <iostream>
  6. #include<string>
  7. #include <algorithm>
  8. #include <list>
  9. #define ALIVE 1
  10. #define DEAD 0
  11. class human
  12. {
  13. std::string m_name{};
  14. bool m_alive{};
  15. std::shared_ptr<human> m_father{};
  16. std::shared_ptr<human> m_mother{};
  17. std::list<std::weak_ptr<human>> m_children;
  18. public:
  19. human(const std::string name, bool alive = ALIVE)
  20. : m_name(name), m_alive(alive) {};
  21. human(const human&) = delete;
  22. human(human&&)noexcept;
  23. ~human() { m_alive = DEAD; };
  24. human& operator=(const human&) = default;
  25. static std::shared_ptr<human> child(std::string name, std::shared_ptr<human>& pmother, std::shared_ptr<human>& pfather);
  26. void print_parents(void);
  27. void print_children(void);
  28. void print_three(void);
  29. };