feat(ex00): it works

This commit is contained in:
Khaïs COLIN 2025-05-12 12:01:05 +02:00
parent 8cfb880a3a
commit b9ff91c653
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
7 changed files with 57 additions and 1 deletions

1
ex00/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
ex00

View file

@ -9,7 +9,12 @@ endif
ifeq ($(CXX),g++) ifeq ($(CXX),g++)
CXX = c++ CXX = c++
endif endif
main_objs = $(addsuffix .o,$(NAME)) srcs = \
Zombie.cpp \
newZombie.cpp \
randomChump.cpp \
main_objs = main.o $(srcs:.cpp=.o)
all_objs = $(main_objs) all_objs = $(main_objs)
deps = $(all_objs:.o=.d) deps = $(all_objs:.o=.d)

10
ex00/Zombie.cpp Normal file
View file

@ -0,0 +1,10 @@
#include "Zombie.hpp"
#include <iostream>
void Zombie::announce(void) {
std::cout << name << ": " << "BraiiiiiiinnnzzzZ..." << std::endl;
}
Zombie::Zombie(std::string name) { this->name = name; }
Zombie::~Zombie() { std::cout << name << " is heading out." << std::endl; }

20
ex00/Zombie.hpp Normal file
View file

@ -0,0 +1,20 @@
#ifndef ZOMBIE_HPP
#define ZOMBIE_HPP
#include <string>
class Zombie {
public:
Zombie(std::string name);
~Zombie();
void announce(void);
private:
std::string name;
};
Zombie *newZombie(std::string name);
void randomChump(std::string name);
#endif

8
ex00/main.cpp Normal file
View file

@ -0,0 +1,8 @@
#include "Zombie.hpp"
int main() {
Zombie *zombie = newZombie("Bob");
zombie->announce();
delete zombie;
randomChump("Alex");
return 0;
}

6
ex00/newZombie.cpp Normal file
View file

@ -0,0 +1,6 @@
#include "Zombie.hpp"
Zombie *newZombie(std::string name) {
Zombie *zombie = new Zombie(name);
return zombie;
}

6
ex00/randomChump.cpp Normal file
View file

@ -0,0 +1,6 @@
#include "Zombie.hpp"
void randomChump(std::string name) {
Zombie zombie = Zombie(name);
zombie.announce();
}