diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-12-12 12:33:39 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-12-12 12:33:39 +0100 |
| commit | 0071b1e944cbce91ff6ff8e235280c3955ce1d5b (patch) | |
| tree | af908c41fc051002311f50e8f73b889769a5279e /cpp05/ex01 | |
| parent | c10aa969c60cedef893146307fa319250901465a (diff) | |
| download | piscine_cpp-0071b1e944cbce91ff6ff8e235280c3955ce1d5b.tar.gz piscine_cpp-0071b1e944cbce91ff6ff8e235280c3955ce1d5b.tar.bz2 piscine_cpp-0071b1e944cbce91ff6ff8e235280c3955ce1d5b.zip | |
Fixing cpp05 small errors
Diffstat (limited to 'cpp05/ex01')
| -rw-r--r-- | cpp05/ex01/Bureaucrat.cpp | 11 | ||||
| -rw-r--r-- | cpp05/ex01/Bureaucrat.hpp | 8 | ||||
| -rw-r--r-- | cpp05/ex01/main.cpp | 12 |
3 files changed, 16 insertions, 15 deletions
diff --git a/cpp05/ex01/Bureaucrat.cpp b/cpp05/ex01/Bureaucrat.cpp index 1024d54..2c1dd46 100644 --- a/cpp05/ex01/Bureaucrat.cpp +++ b/cpp05/ex01/Bureaucrat.cpp @@ -6,17 +6,18 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 18:08:13 by charles #+# #+# */ -/* Updated: 2020/11/17 12:08:02 by cacharle ### ########.fr */ +/* Updated: 2020/12/12 11:58:39 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; + // m_name = other.m_name; m_grade = other.m_grade; return *this; } @@ -44,7 +45,7 @@ void Bureaucrat::decrementGrade() checkGrade(); } -void Bureaucrat::signForm(Form& form) +void Bureaucrat::signForm(Form& form) const { try { @@ -53,7 +54,7 @@ void Bureaucrat::signForm(Form& form) } catch (std::exception &e) { - std::cout << m_name << " cannot sign " << form.getName() << " " << e.what() << std::endl; + std::cout << m_name << " cannot sign " << form.getName() << " because " << e.what() << std::endl; } } diff --git a/cpp05/ex01/Bureaucrat.hpp b/cpp05/ex01/Bureaucrat.hpp index 1886a76..3317021 100644 --- a/cpp05/ex01/Bureaucrat.hpp +++ b/cpp05/ex01/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 18:04:32 by charles #+# #+# */ -/* Updated: 2020/11/17 11:32:12 by cacharle ### ########.fr */ +/* Updated: 2020/12/12 11:49:39 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,14 +33,14 @@ public: void incrementGrade(); void decrementGrade(); - void signForm(Form& form); + void signForm(Form& form) const; 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/ex01/main.cpp b/cpp05/ex01/main.cpp index 3200b0f..75091f3 100644 --- a/cpp05/ex01/main.cpp +++ b/cpp05/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 18:13:05 by charles #+# #+# */ -/* Updated: 2020/11/17 12:10:38 by cacharle ### ########.fr */ +/* Updated: 2020/12/12 11:56:20 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,7 @@ 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; @@ -64,10 +64,10 @@ int main() Bureaucrat c("baraucrat", 10); std::cout << "############### SIGN FORM" << std::endl; - Form f4("foo", 150, 1); c.signForm(f4); - Form f3("foo", 10, 1); c.signForm(f3); - Form f2("foo", 9, 1); c.signForm(f2); - Form f1("foo", 1, 1); c.signForm(f1); + Form f4("foo1", 150, 1); c.signForm(f4); + Form f3("foo2", 10, 1); c.signForm(f3); + Form f2("foo3", 9, 1); c.signForm(f2); + Form f1("foo4", 1, 1); c.signForm(f1); } std::cout << std::endl; |
