d01 ex03 ref and ptr

This commit is contained in:
Hugo LAMY
2022-02-06 17:59:33 +01:00
parent 3708a135be
commit e165ba887d
7 changed files with 15 additions and 16 deletions

View File

@@ -1,19 +1,19 @@
#include "HumanA.hpp"
HumanA::HumanA( std::string name, Weapon weapon ) {
HumanA::HumanA( std::string name, Weapon &weapon ) : _weapon( weapon ) {
this->_name = name;
this->_weapon = &weapon;
// this->_weapon = weapon;
return;
}
HumanA::~HumanA() {return;}
void HumanA::attack( void ) {
void HumanA::attack( void ) const {
std::cout << this->_name << " attacks with their ";
std::cout << this->_weapon->getType() << std::endl;
std::cout << this->_weapon.getType() << std::endl;
return;