From 1de596dd9242b677d6b47b51db98ce98feb95465 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Mon, 14 Dec 2020 15:30:28 +0100 Subject: Updated cpp07 files with new subject --- cpp07/ex02/Array.hpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'cpp07/ex02/Array.hpp') 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 +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 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; }; -- cgit