diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-15 17:24:46 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-15 17:24:46 +0100 |
| commit | 62be117da22b5159c8712537ac7ef135ff3007b8 (patch) | |
| tree | 2a0447d54264465db0878fe19160759220043672 /cpp04/ex03/Character.cpp | |
| parent | 4c30e98f4a4018a25d3a9f3ee790d589be803cb0 (diff) | |
| download | piscine_cpp-62be117da22b5159c8712537ac7ef135ff3007b8.tar.gz piscine_cpp-62be117da22b5159c8712537ac7ef135ff3007b8.tar.bz2 piscine_cpp-62be117da22b5159c8712537ac7ef135ff3007b8.zip | |
Fixing cpp04/03 crash
Diffstat (limited to 'cpp04/ex03/Character.cpp')
| -rw-r--r-- | cpp04/ex03/Character.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cpp04/ex03/Character.cpp b/cpp04/ex03/Character.cpp index d159aaf..bc58588 100644 --- a/cpp04/ex03/Character.cpp +++ b/cpp04/ex03/Character.cpp @@ -6,12 +6,15 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 16:45:54 by charles #+# #+# */ -/* Updated: 2020/11/13 14:20:50 by cacharle ### ########.fr */ +/* Updated: 2020/11/15 17:10:46 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "Character.hpp" +Character::Character(std::string const& name) + : m_name(name), m_inventory_size(0) {} + Character::Character(Character const& other) : m_inventory_size(0) { *this = other; } @@ -27,13 +30,11 @@ Character& Character::operator=(Character const& other) Character::~Character() { destroyInventory(); } -Character::Character(std::string const& name) : m_name(name), m_inventory_size(0) {} - std::string const& Character::getName() const { return m_name; } void Character::equip(AMateria* m) { - if (m_inventory_size >= INVENTORY_MAX_SIZE) + if (m_inventory_size >= INVENTORY_MAX_SIZE || m == NULL) return; m_inventory[m_inventory_size] = m; m_inventory_size++; |
