12345678910111213141516171819202122232425262728293031323334 |
- #pragma once
- #pragma once
- #include<iterator>
- #include <memory>
- #include <iostream>
- #include<string>
- #include <algorithm>
- #include <list>
- #define ALIVE 1
- #define DEAD 0
- class human
- {
- std::string m_name{};
- bool m_alive{};
- std::shared_ptr<human> m_father{};
- std::shared_ptr<human> m_mother{};
- std::list<std::weak_ptr<human>> m_children;
- public:
- human(const std::string name, bool alive = ALIVE)
- : m_name(name), m_alive(alive) {};
- human(const human&) = delete;
- human(human&&)noexcept;
- ~human() { m_alive = DEAD; };
- human& operator=(const human&) = default;
-
- static std::shared_ptr<human> child(std::string name, std::shared_ptr<human>& pmother, std::shared_ptr<human>& pfather);
-
- void print_parents(void);
- void print_children(void);
- void print_three(void);
- };
|