aboutsummaryrefslogtreecommitdiff
path: root/cpp04/ex02
diff options
context:
space:
mode:
Diffstat (limited to 'cpp04/ex02')
-rw-r--r--cpp04/ex02/AssaultTerminator.cpp10
-rw-r--r--cpp04/ex02/AssaultTerminator.hpp4
-rw-r--r--cpp04/ex02/Squad.cpp24
-rw-r--r--cpp04/ex02/Squad.hpp5
-rw-r--r--cpp04/ex02/TacticalMarine.cpp10
-rw-r--r--cpp04/ex02/TacticalMarine.hpp4
6 files changed, 22 insertions, 35 deletions
diff --git a/cpp04/ex02/AssaultTerminator.cpp b/cpp04/ex02/AssaultTerminator.cpp
index 40518da..c00a00c 100644
--- a/cpp04/ex02/AssaultTerminator.cpp
+++ b/cpp04/ex02/AssaultTerminator.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:47:06 by charles #+# #+# */
-/* Updated: 2020/04/14 15:51:46 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:37:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,14 +17,12 @@ AssaultTerminator::AssaultTerminator()
std::cout << "* teleports from space *" << std::endl;
}
-AssaultTerminator::AssaultTerminator(AssaultTerminator const& other)
-{
- *this = other;
-}
+AssaultTerminator::AssaultTerminator(AssaultTerminator const& other) { *this = other; }
-void AssaultTerminator::operator=(AssaultTerminator const& other)
+AssaultTerminator& AssaultTerminator::operator=(AssaultTerminator const& other)
{
(void)other;
+ return *this;
}
AssaultTerminator::~AssaultTerminator()
diff --git a/cpp04/ex02/AssaultTerminator.hpp b/cpp04/ex02/AssaultTerminator.hpp
index e2d7acd..b2064f1 100644
--- a/cpp04/ex02/AssaultTerminator.hpp
+++ b/cpp04/ex02/AssaultTerminator.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:46:20 by charles #+# #+# */
-/* Updated: 2020/04/14 15:52:47 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:36:54 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class AssaultTerminator : public ISpaceMarine
public:
AssaultTerminator();
AssaultTerminator(AssaultTerminator const& other);
- void operator=(AssaultTerminator const& other);
+ AssaultTerminator& operator=(AssaultTerminator const& other);
virtual ~AssaultTerminator();
virtual ISpaceMarine* clone() const;
diff --git a/cpp04/ex02/Squad.cpp b/cpp04/ex02/Squad.cpp
index 11c7862..d1d988f 100644
--- a/cpp04/ex02/Squad.cpp
+++ b/cpp04/ex02/Squad.cpp
@@ -6,39 +6,29 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:08:35 by charles #+# #+# */
-/* Updated: 2020/04/15 10:06:04 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:38:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Squad.hpp"
-Squad::Squad() : m_units(new ISpaceMarine*[0]), m_size(0)
-{
-}
+Squad::Squad() : m_units(new ISpaceMarine*[0]), m_size(0) {}
-Squad::Squad(Squad const& other)
-{
- *this = other;
-}
+Squad::Squad(Squad const& other) { *this = other; }
-void Squad::operator=(Squad const& other)
+Squad& Squad::operator=(Squad const& other)
{
destroyUnits();
m_size = other.m_size;
m_units = new ISpaceMarine*[m_size];
for (int i = 0; i < m_size; i++)
m_units[i] = other.m_units[i]->clone();
+ return *this;
}
-Squad::~Squad()
-{
- destroyUnits();
-}
+Squad::~Squad() { destroyUnits(); }
-int Squad::getCount() const
-{
- return m_size;
-}
+int Squad::getCount() const { return m_size; }
ISpaceMarine* Squad::getUnit(int n) const
{
diff --git a/cpp04/ex02/Squad.hpp b/cpp04/ex02/Squad.hpp
index fda1148..9ea5268 100644
--- a/cpp04/ex02/Squad.hpp
+++ b/cpp04/ex02/Squad.hpp
@@ -6,13 +6,14 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:07:57 by charles #+# #+# */
-/* Updated: 2020/04/14 15:28:02 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:39:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SQUAD_HPP
# define SQUAD_HPP
+# include <cstdlib>
# include "ISquad.hpp"
# include "ISpaceMarine.hpp"
@@ -21,7 +22,7 @@ class Squad : public ISquad
public:
Squad();
Squad(Squad const& other);
- void operator=(Squad const& other);
+ Squad& operator=(Squad const& other);
virtual ~Squad();
virtual int getCount() const;
diff --git a/cpp04/ex02/TacticalMarine.cpp b/cpp04/ex02/TacticalMarine.cpp
index f2684ba..df771e8 100644
--- a/cpp04/ex02/TacticalMarine.cpp
+++ b/cpp04/ex02/TacticalMarine.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:31:43 by charles #+# #+# */
-/* Updated: 2020/04/14 15:45:55 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:37:41 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,14 +17,12 @@ TacticalMarine::TacticalMarine()
std::cout << "Tactical Marine ready for battle!" << std::endl;
}
-TacticalMarine::TacticalMarine(TacticalMarine const& other)
-{
- *this = other;
-}
+TacticalMarine::TacticalMarine(TacticalMarine const& other) { *this = other; }
-void TacticalMarine::operator=(TacticalMarine const& other)
+TacticalMarine& TacticalMarine::operator=(TacticalMarine const& other)
{
(void)other;
+ return *this;
}
TacticalMarine::~TacticalMarine()
diff --git a/cpp04/ex02/TacticalMarine.hpp b/cpp04/ex02/TacticalMarine.hpp
index 18dd0c9..43722d6 100644
--- a/cpp04/ex02/TacticalMarine.hpp
+++ b/cpp04/ex02/TacticalMarine.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:30:48 by charles #+# #+# */
-/* Updated: 2020/04/14 15:34:12 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:38:03 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class TacticalMarine : public ISpaceMarine
public:
TacticalMarine();
TacticalMarine(TacticalMarine const& other);
- void operator=(TacticalMarine const& other);
+ TacticalMarine& operator=(TacticalMarine const& other);
virtual ~TacticalMarine();
virtual ISpaceMarine* clone() const;