recreation of ex00
This commit is contained in:
@ -1,19 +1,35 @@
|
||||
#include "Zombie.hpp"
|
||||
#include <string>
|
||||
#include "./Zombie.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
Zombie::Zombie(std::string name)
|
||||
Zombie::Zombie()
|
||||
{
|
||||
this->name = name;
|
||||
std::cout << this->name << ": " << "Zombie()" << std::endl;
|
||||
std::cout << "Zombie()" << std::endl;
|
||||
}
|
||||
|
||||
Zombie::Zombie(const std::string& name)
|
||||
{
|
||||
std::cout << "Zombie(" << name << ")" << std::endl;
|
||||
this->_name = name;
|
||||
}
|
||||
|
||||
Zombie::Zombie(const Zombie& src)
|
||||
{
|
||||
*this = src;
|
||||
}
|
||||
|
||||
Zombie::~Zombie()
|
||||
{
|
||||
std::cout << this->name << ": " << "~Zombie()" << std::endl;
|
||||
std::cout << "~Zombie()" << std::endl;
|
||||
}
|
||||
|
||||
void Zombie::announce() const
|
||||
Zombie& Zombie::operator=(const Zombie& src)
|
||||
{
|
||||
std::cout << this->name << ": " << "BraiiiiiiinnnzzzZ..." << std::endl;
|
||||
this->_name = src._name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Zombie::announe()
|
||||
{
|
||||
std::cout << this->_name << ": BraiiiiiiinnnzzzZ..." << std::endl;
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Zombie {
|
||||
|
||||
class Zombie
|
||||
{
|
||||
private:
|
||||
std::string name;
|
||||
|
||||
public:
|
||||
Zombie(std::string name);
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
Zombie(const Zombie& src);
|
||||
Zombie();
|
||||
Zombie(const std::string& name);
|
||||
~Zombie();
|
||||
|
||||
void announce(void) const;
|
||||
void setName(std::string name);
|
||||
Zombie& operator=(const Zombie& src);
|
||||
|
||||
void announe(void);
|
||||
};
|
||||
|
||||
Zombie* newZombie(std::string name);
|
||||
void randomChump(std::string name);
|
||||
void randomChump(std::string name);
|
||||
Zombie* newZombie(std::string name);
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "Zombie.hpp"
|
||||
|
||||
int main()
|
||||
int main()
|
||||
{
|
||||
Zombie* jean;
|
||||
Zombie pierre("Pierre");
|
||||
|
||||
jean = new Zombie("jean");
|
||||
jean->announce();
|
||||
Zombie* jean = newZombie("jean");
|
||||
jean->announe();
|
||||
delete jean;
|
||||
randomChump("francois");
|
||||
|
||||
Zombie no_name;
|
||||
no_name.announe();
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,8 +2,5 @@
|
||||
|
||||
Zombie* newZombie(std::string name)
|
||||
{
|
||||
Zombie* zombie;
|
||||
|
||||
zombie = new Zombie(name);
|
||||
return (zombie);
|
||||
return new Zombie(name);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "Zombie.hpp"
|
||||
#include <string>
|
||||
|
||||
void randomChump(std::string name)
|
||||
{
|
||||
Zombie zombie(name);
|
||||
|
||||
zombie.announce();
|
||||
zombie.announe();
|
||||
}
|
||||
|
Reference in New Issue
Block a user