aboutsummaryrefslogtreecommitdiff
path: root/cpp04/ex03/Character.cpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-17 09:36:17 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-17 09:36:17 +0100
commit4eecb32ffcf48c42672782fbcd53781a22e95ebf (patch)
treecef35987dc325ed2f0a8e5085f9e7a18554367fe /cpp04/ex03/Character.cpp
parent62be117da22b5159c8712537ac7ef135ff3007b8 (diff)
downloadpiscine_cpp-4eecb32ffcf48c42672782fbcd53781a22e95ebf.tar.gz
piscine_cpp-4eecb32ffcf48c42672782fbcd53781a22e95ebf.tar.bz2
piscine_cpp-4eecb32ffcf48c42672782fbcd53781a22e95ebf.zip
Added cpp04/ex03 main
Diffstat (limited to 'cpp04/ex03/Character.cpp')
-rw-r--r--cpp04/ex03/Character.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/cpp04/ex03/Character.cpp b/cpp04/ex03/Character.cpp
index bc58588..57fcfeb 100644
--- a/cpp04/ex03/Character.cpp
+++ b/cpp04/ex03/Character.cpp
@@ -6,14 +6,14 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:45:54 by charles #+# #+# */
-/* Updated: 2020/11/15 17:10:46 by charles ### ########.fr */
+/* Updated: 2020/11/17 08:30:21 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Character.hpp"
Character::Character(std::string const& name)
- : m_name(name), m_inventory_size(0) {}
+ : m_inventory_size(0), m_name(name) {}
Character::Character(Character const& other)
: m_inventory_size(0) { *this = other; }
@@ -44,6 +44,7 @@ void Character::unequip(int idx)
{
if (idx < 0 || idx >= m_inventory_size)
return;
+ delete m_inventory[idx];
for (int i = idx; i < m_inventory_size - 1; i++)
m_inventory[i] = m_inventory[i + 1];
m_inventory_size--;