aboutsummaryrefslogtreecommitdiff
path: root/cpp05/ex00
diff options
context:
space:
mode:
Diffstat (limited to 'cpp05/ex00')
-rw-r--r--cpp05/ex00/Bureaucrat.cpp17
-rw-r--r--cpp05/ex00/Bureaucrat.hpp8
2 files changed, 17 insertions, 8 deletions
diff --git a/cpp05/ex00/Bureaucrat.cpp b/cpp05/ex00/Bureaucrat.cpp
index 69ca053..5737939 100644
--- a/cpp05/ex00/Bureaucrat.cpp
+++ b/cpp05/ex00/Bureaucrat.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:08:13 by charles #+# #+# */
-/* Updated: 2020/04/14 18:44:49 by charles ### ########.fr */
+/* Updated: 2020/10/19 13:26:35 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,9 +17,10 @@ Bureaucrat::Bureaucrat(Bureaucrat const& other)
*this = other;
}
-void Bureaucrat::operator=(Bureaucrat const& other)
+Bureaucrat& Bureaucrat::operator=(Bureaucrat const& other)
{
m_grade = other.m_grade;
+ return *this;
}
Bureaucrat::~Bureaucrat()
@@ -56,6 +57,10 @@ void Bureaucrat::decrementGrade()
m_grade++;
}
+///////////////////////////////////////////////////////////////////////////////
+// Exceptions
+///////////////////////////////////////////////////////////////////////////////
+
Bureaucrat::GradeTooHighException::GradeTooHighException() : std::exception()
{}
@@ -63,9 +68,11 @@ Bureaucrat::GradeTooHighException::GradeTooHighException(GradeTooHighException c
: std::exception(other)
{}
-void Bureaucrat::GradeTooHighException::operator=(GradeTooHighException const& other)
+Bureaucrat::GradeTooHighException&
+Bureaucrat::GradeTooHighException::operator=(GradeTooHighException const& other)
{
std::exception::operator=(other);
+ return *this;
}
Bureaucrat::GradeTooHighException::~GradeTooHighException()
@@ -83,9 +90,11 @@ Bureaucrat::GradeTooLowException::GradeTooLowException(GradeTooLowException cons
: std::exception(other)
{}
-void Bureaucrat::GradeTooLowException::operator=(GradeTooLowException const& other)
+Bureaucrat::GradeTooLowException&
+Bureaucrat::GradeTooLowException::operator=(GradeTooLowException const& other)
{
std::exception::operator=(other);
+ return *this;
}
Bureaucrat::GradeTooLowException::~GradeTooLowException()
diff --git a/cpp05/ex00/Bureaucrat.hpp b/cpp05/ex00/Bureaucrat.hpp
index 8cb328e..7734725 100644
--- a/cpp05/ex00/Bureaucrat.hpp
+++ b/cpp05/ex00/Bureaucrat.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:04:32 by charles #+# #+# */
-/* Updated: 2020/04/14 18:42:13 by charles ### ########.fr */
+/* Updated: 2020/10/19 13:26:06 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,7 @@ class Bureaucrat
{
public:
Bureaucrat(Bureaucrat const& other);
- void operator=(Bureaucrat const& other);
+ Bureaucrat& operator=(Bureaucrat const& other);
~Bureaucrat();
Bureaucrat(std::string const& name, int grade);
@@ -34,7 +34,7 @@ public:
public:
GradeTooHighException();
GradeTooHighException(GradeTooHighException const& other);
- void operator=(GradeTooHighException const& other);
+ GradeTooHighException& operator=(GradeTooHighException const& other);
~GradeTooHighException();
virtual char const* what() const throw();
};
@@ -44,7 +44,7 @@ public:
public:
GradeTooLowException();
GradeTooLowException(GradeTooLowException const& other);
- void operator=(GradeTooLowException const& other);
+ GradeTooLowException& operator=(GradeTooLowException const& other);
~GradeTooLowException();
virtual char const* what() const throw();
};