From aa40eb5dedd39263ff511de01d6833d24e33b736 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 10 Nov 2020 14:50:38 +0100 Subject: Changing operator= and const reference in Traps --- cpp03/ex03/NinjaTrap.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cpp03/ex03/NinjaTrap.cpp') diff --git a/cpp03/ex03/NinjaTrap.cpp b/cpp03/ex03/NinjaTrap.cpp index 2a27eec..bdc3534 100644 --- a/cpp03/ex03/NinjaTrap.cpp +++ b/cpp03/ex03/NinjaTrap.cpp @@ -6,14 +6,13 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 17:33:00 by charles #+# #+# */ -/* Updated: 2020/04/13 17:47:20 by charles ### ########.fr */ +/* Updated: 2020/11/10 14:43:25 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "NinjaTrap.hpp" -NinjaTrap::NinjaTrap(): - ClapTrap() +NinjaTrap::NinjaTrap() : ClapTrap() { m_prefix = "NINJ4-TP "; m_hitPoints = 60; @@ -26,8 +25,7 @@ NinjaTrap::NinjaTrap(): std::cout << m_prefix << "New " << m_name << ": your gaming references suck" << std::endl; } -NinjaTrap::NinjaTrap(std::string name): - ClapTrap(name) +NinjaTrap::NinjaTrap(std::string const& name) : ClapTrap(name) { m_prefix = "NINJ4-TP "; m_hitPoints = 60; @@ -45,7 +43,7 @@ NinjaTrap::NinjaTrap(NinjaTrap const& other) *this = other; } -void NinjaTrap::operator=(NinjaTrap const& other) +NinjaTrap& NinjaTrap::operator=(NinjaTrap const& other) { m_hitPoints = other.m_hitPoints; m_maxHitPoints = other.m_maxHitPoints; @@ -55,6 +53,7 @@ void NinjaTrap::operator=(NinjaTrap const& other) m_meleeAttackDamage = other.m_meleeAttackDamage; m_rangedAttackDamage = other.m_rangedAttackDamage; m_armorDamageReduction = other.m_armorDamageReduction; + return *this; } NinjaTrap::~NinjaTrap() -- cgit