aboutsummaryrefslogtreecommitdiff
path: root/cpp07/ex02/Array.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp07/ex02/Array.hpp')
-rw-r--r--cpp07/ex02/Array.hpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/cpp07/ex02/Array.hpp b/cpp07/ex02/Array.hpp
index fec8698..0dc53c4 100644
--- a/cpp07/ex02/Array.hpp
+++ b/cpp07/ex02/Array.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 20:14:07 by charles #+# #+# */
-/* Updated: 2020/04/14 20:41:25 by charles ### ########.fr */
+/* Updated: 2020/12/14 15:26:51 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,31 +19,30 @@ template<typename T>
class Array
{
public:
- Array() : m_under(new T[0]), m_size(0)
- {}
+ Array()
+ : m_under(new T[0]), m_size(0) {}
- Array(unsigned int n) : m_under(new T[n]()), m_size(n)
- {}
+ Array(unsigned int n)
+ : m_under(new T[n]()), m_size(n) {}
- Array(Array const& other) : m_under(new T[other.m_size]), m_size(other.m_size)
+ Array(Array const& other)
+ : m_under(new T[other.m_size]), m_size(other.m_size)
{
for (unsigned int i = 0; i < m_size; i++)
m_under[i] = other.m_under[i];
}
- void operator=(Array const& other)
+ Array& operator=(Array const& other)
{
delete [] m_under;
- m_size = other.m_size;
+ m_size = other.m_size;
m_under = new T[m_size];
for (unsigned int i = 0; i < m_size; i++)
m_under[i] = other.m_under[i];
+ return *this;
}
- ~Array()
- {
- delete [] m_under;
- }
+ ~Array() { delete [] m_under; }
T& operator[](unsigned int n)
{
@@ -59,13 +58,10 @@ public:
return m_under[n];
}
- unsigned int size() const
- {
- return m_size;
- }
+ unsigned int size() const { return m_size; }
private:
- T* m_under;
+ T* m_under;
unsigned int m_size;
};