From 0071b1e944cbce91ff6ff8e235280c3955ce1d5b Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 12 Dec 2020 12:33:39 +0100 Subject: Fixing cpp05 small errors --- cpp05/ex00/Bureaucrat.cpp | 7 ++++--- cpp05/ex00/Bureaucrat.hpp | 6 +++--- cpp05/ex00/main.cpp | 5 ++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'cpp05/ex00') diff --git a/cpp05/ex00/Bureaucrat.cpp b/cpp05/ex00/Bureaucrat.cpp index 927d467..3385089 100644 --- a/cpp05/ex00/Bureaucrat.cpp +++ b/cpp05/ex00/Bureaucrat.cpp @@ -6,17 +6,18 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 18:08:13 by charles #+# #+# */ -/* Updated: 2020/11/17 10:23:23 by cacharle ### ########.fr */ +/* Updated: 2020/12/12 11:35:48 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "Bureaucrat.hpp" -Bureaucrat::Bureaucrat(Bureaucrat const& other) { *this = other; } +Bureaucrat::Bureaucrat(Bureaucrat const& other) + : m_name(other.m_name) { *this = other; } Bureaucrat& Bureaucrat::operator=(Bureaucrat const& other) { - m_name = other.m_name; + // cannot copy other.m_name since it's constant m_grade = other.m_grade; return *this; } diff --git a/cpp05/ex00/Bureaucrat.hpp b/cpp05/ex00/Bureaucrat.hpp index 222d219..1d0c076 100644 --- a/cpp05/ex00/Bureaucrat.hpp +++ b/cpp05/ex00/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 18:04:32 by charles #+# #+# */ -/* Updated: 2020/11/17 10:28:41 by cacharle ### ########.fr */ +/* Updated: 2020/12/12 11:34:29 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,8 +34,8 @@ private: Bureaucrat(); void checkGrade(); - std::string m_name; - int m_grade; + std::string const m_name; + int m_grade; class GradeTooHighException : public std::exception { diff --git a/cpp05/ex00/main.cpp b/cpp05/ex00/main.cpp index 90092cf..e0b3edf 100644 --- a/cpp05/ex00/main.cpp +++ b/cpp05/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 18:13:05 by charles #+# #+# */ -/* Updated: 2020/11/17 11:51:33 by cacharle ### ########.fr */ +/* Updated: 2020/12/12 11:41:15 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,13 +22,12 @@ int main() Bureaucrat yep("YEP", 1); Bureaucrat yep2(yep); - Bureaucrat yep3("SHOULD NOT BE PRINTED", 42); + Bureaucrat yep3("SHOULD NOT BE OVERWRITTEN", 42); yep3 = yep; std::cout << yep; std::cout << yep2; std::cout << yep3; - std::cout << std::endl; std::cout << "############### DECREMENT" << std::endl; Bureaucrat a("jean", 140); -- cgit