feat(ex00): it works
This commit is contained in:
parent
8cfb880a3a
commit
b9ff91c653
7 changed files with 57 additions and 1 deletions
1
ex00/.gitignore
vendored
Normal file
1
ex00/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
ex00
|
||||
|
|
@ -9,7 +9,12 @@ endif
|
|||
ifeq ($(CXX),g++)
|
||||
CXX = c++
|
||||
endif
|
||||
main_objs = $(addsuffix .o,$(NAME))
|
||||
srcs = \
|
||||
Zombie.cpp \
|
||||
newZombie.cpp \
|
||||
randomChump.cpp \
|
||||
|
||||
main_objs = main.o $(srcs:.cpp=.o)
|
||||
all_objs = $(main_objs)
|
||||
deps = $(all_objs:.o=.d)
|
||||
|
||||
|
|
|
|||
10
ex00/Zombie.cpp
Normal file
10
ex00/Zombie.cpp
Normal 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
20
ex00/Zombie.hpp
Normal 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
8
ex00/main.cpp
Normal 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
6
ex00/newZombie.cpp
Normal 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
6
ex00/randomChump.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include "Zombie.hpp"
|
||||
|
||||
void randomChump(std::string name) {
|
||||
Zombie zombie = Zombie(name);
|
||||
zombie.announce();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue