aboutsummaryrefslogtreecommitdiff
path: root/cpp04/ex03/Character.cpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-12 15:46:07 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-12 15:46:07 +0100
commitb8e39b947890e74d82530e25ad9d02668aae1f0c (patch)
treef59acfdecb0711137c200a4c5acb854e351f9cf9 /cpp04/ex03/Character.cpp
parent96dcf214a8c40529b251ea31ef037868583dd1da (diff)
downloadpiscine_cpp-b8e39b947890e74d82530e25ad9d02668aae1f0c.tar.gz
piscine_cpp-b8e39b947890e74d82530e25ad9d02668aae1f0c.tar.bz2
piscine_cpp-b8e39b947890e74d82530e25ad9d02668aae1f0c.zip
Reformating cpp04 classes
Diffstat (limited to 'cpp04/ex03/Character.cpp')
-rw-r--r--cpp04/ex03/Character.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/cpp04/ex03/Character.cpp b/cpp04/ex03/Character.cpp
index 34aaa48..ee03e63 100644
--- a/cpp04/ex03/Character.cpp
+++ b/cpp04/ex03/Character.cpp
@@ -6,22 +6,17 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:45:54 by charles #+# #+# */
-/* Updated: 2020/04/14 17:59:57 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:43:14 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Character.hpp"
-Character::Character() : m_name(""), m_inventory_size(0)
-{
-}
+Character::Character() : m_name(""), m_inventory_size(0) {}
-Character::Character(Character const& other)
-{
- *this = other;
-}
+Character::Character(Character const& other) { *this = other; }
-void Character::operator=(Character const& other)
+Character& Character::operator=(Character const& other)
{
for (int i = 0; i < m_inventory_size; i++)
delete m_inventory[i];
@@ -29,6 +24,7 @@ void Character::operator=(Character const& other)
for (int i = 0; i < m_inventory_size; i++)
m_inventory[i] = other.m_inventory[i]->clone();
m_name = other.m_name;
+ return *this;
}
Character::~Character()
@@ -37,15 +33,9 @@ Character::~Character()
delete m_inventory[i];
}
-Character::Character(std::string const& name)
- : m_name(name), m_inventory_size(0)
-{
-}
+Character::Character(std::string const& name) : m_name(name), m_inventory_size(0) {}
-std::string const& Character::getName() const
-{
- return m_name;
-}
+std::string const& Character::getName() const { return m_name; }
void Character::equip(AMateria* m)
{