aboutsummaryrefslogtreecommitdiff
path: root/cpp00/ex01/PhoneBook.cpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-09 11:26:50 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-09 11:26:50 +0100
commitb799c007a1b6911fcbe5141429ea541e1277ebdd (patch)
treed70ad0826ad2fc2d635adf9afecf89af0838d20b /cpp00/ex01/PhoneBook.cpp
parent1e9d90bdf9ef5fc05093d3449d883597c7f896de (diff)
downloadpiscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.gz
piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.bz2
piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.zip
Fixing some edge cases in cpp00 and cpp01, Updated formatting
Diffstat (limited to 'cpp00/ex01/PhoneBook.cpp')
-rw-r--r--cpp00/ex01/PhoneBook.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/cpp00/ex01/PhoneBook.cpp b/cpp00/ex01/PhoneBook.cpp
index a47307f..a28ce36 100644
--- a/cpp00/ex01/PhoneBook.cpp
+++ b/cpp00/ex01/PhoneBook.cpp
@@ -6,23 +6,23 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 07:23:13 by charles #+# #+# */
-/* Updated: 2020/04/13 08:43:05 by charles ### ########.fr */
+/* Updated: 2020/11/09 09:29:37 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "PhoneBook.hpp"
-PhoneBook::PhoneBook(): m_size(0)
-{
-}
+PhoneBook::PhoneBook() : m_size(0) {}
void PhoneBook::add(Contact contact)
{
+ if (m_size >= CONTACTS_SIZE)
+ return;
m_contacts[m_size] = contact;
m_size++;
}
-Contact const &PhoneBook::get(int index) const
+Contact const& PhoneBook::get(size_t index) const
{
return m_contacts[index];
}
@@ -32,7 +32,7 @@ size_t PhoneBook::getSize() const
return m_size;
}
-std::ostream &operator<<(std::ostream &out, PhoneBook const &p)
+std::ostream& operator<<(std::ostream& out, PhoneBook const& p)
{
for (size_t i = 0; i < p.getSize(); i++)
{