add: ex02

This commit is contained in:
starnakin 2023-07-18 03:18:33 +02:00
parent 095cc3dc18
commit 76d822b831
2 changed files with 7 additions and 8 deletions

View File

@ -1,15 +1,17 @@
#include "Zombie.hpp"
#include <cstddef>
int main()
{
Zombie* jean = zombieHorde(2, "jean");
delete[] jean;
Zombie* bob = zombieHorde(-1, "bob");
if (bob == NULL)
return 1;
bob->announe();
Zombie* bob = zombieHorde(4, "bob");
for (size_t i = 0; i < 4; i++)
bob[i].announe();
delete[] bob;
Zombie* pierre = zombieHorde(-1, "pierre");
if (pierre == NULL)
return 1;
return 0;
}

View File

@ -7,9 +7,6 @@ Zombie* zombieHorde(int N, std::string name)
return NULL;
Zombie* zombies = new Zombie[N];
for (int i = 0; i < N; i++)
{
zombies[i].setName(name);
zombies[i].announe();
}
return zombies;
}