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/ex02/FragTrap.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cpp03/ex02/FragTrap.cpp') diff --git a/cpp03/ex02/FragTrap.cpp b/cpp03/ex02/FragTrap.cpp index 4db102e..fc65fcd 100644 --- a/cpp03/ex02/FragTrap.cpp +++ b/cpp03/ex02/FragTrap.cpp @@ -6,14 +6,13 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/22 05:20:45 by cacharle #+# #+# */ -/* Updated: 2020/04/13 15:46:59 by charles ### ########.fr */ +/* Updated: 2020/11/10 14:39:26 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "FragTrap.hpp" -FragTrap::FragTrap(): - ClapTrap() +FragTrap::FragTrap() : ClapTrap() { m_prefix = "FR4G-TP "; m_energyPoints = 100; @@ -24,8 +23,7 @@ FragTrap::FragTrap(): std::cout << "FR4G-TP New " << m_name << ": your gaming references suck" << std::endl; } -FragTrap::FragTrap(std::string name): - ClapTrap(name) +FragTrap::FragTrap(std::string const& name) : ClapTrap(name) { m_prefix = "FR4G-TP "; m_energyPoints = 100; @@ -41,7 +39,7 @@ FragTrap::FragTrap(FragTrap const& other) *this = other; } -void FragTrap::operator=(FragTrap const& other) +FragTrap& FragTrap::operator=(FragTrap const& other) { m_hitPoints = other.m_hitPoints; m_maxHitPoints = other.m_maxHitPoints; @@ -51,6 +49,7 @@ void FragTrap::operator=(FragTrap const& other) m_meleeAttackDamage = other.m_meleeAttackDamage; m_rangedAttackDamage = other.m_rangedAttackDamage; m_armorDamageReduction = other.m_armorDamageReduction; + return *this; } FragTrap::~FragTrap() -- cgit