diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
| commit | b799c007a1b6911fcbe5141429ea541e1277ebdd (patch) | |
| tree | d70ad0826ad2fc2d635adf9afecf89af0838d20b /cpp01/ex03/ZombieHorde.cpp | |
| parent | 1e9d90bdf9ef5fc05093d3449d883597c7f896de (diff) | |
| download | piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.gz piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.bz2 piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.zip | |
Fixing some edge cases in cpp00 and cpp01, Updated formatting
Diffstat (limited to 'cpp01/ex03/ZombieHorde.cpp')
| -rw-r--r-- | cpp01/ex03/ZombieHorde.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cpp01/ex03/ZombieHorde.cpp b/cpp01/ex03/ZombieHorde.cpp index 955355b..0492fb3 100644 --- a/cpp01/ex03/ZombieHorde.cpp +++ b/cpp01/ex03/ZombieHorde.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 09:52:11 by charles #+# #+# */ -/* Updated: 2020/04/13 10:02:01 by charles ### ########.fr */ +/* Updated: 2020/11/09 10:57:08 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,12 @@ ZombieHorde::ZombieHorde(int n) : m_size(n) { + if (n < 0) + { + std::cerr << "Error: n should be > 0" << std::endl; + m_horde = NULL; + return; + } std::string name_pool[10] = { "Jordan", "Mr.poopybutthole", @@ -40,6 +46,8 @@ ZombieHorde::ZombieHorde(int n) ZombieHorde::~ZombieHorde() { + if (m_horde == NULL) + return; for (size_t i = 0; i < m_size; i++) delete m_horde[i]; delete [] m_horde; @@ -47,6 +55,8 @@ ZombieHorde::~ZombieHorde() void ZombieHorde::announce() { + if (m_horde == NULL) + return; for (size_t i = 0; i < m_size; i++) m_horde[i]->announce(); } |
