aboutsummaryrefslogtreecommitdiff
path: root/cpp07/ex02/Array.hpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-12-14 15:30:28 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-12-14 15:30:28 +0100
commit1de596dd9242b677d6b47b51db98ce98feb95465 (patch)
treeacbc79883c0af843b8b999a39f96cefd48e6e390 /cpp07/ex02/Array.hpp
parentb13cd117a7957f9d86ec2986b47349979325a854 (diff)
downloadpiscine_cpp-1de596dd9242b677d6b47b51db98ce98feb95465.tar.gz
piscine_cpp-1de596dd9242b677d6b47b51db98ce98feb95465.tar.bz2
piscine_cpp-1de596dd9242b677d6b47b51db98ce98feb95465.zip
Updated cpp07 files with new subject
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;
};