Skip to content

Commit 6808c84

Browse files
author
izenynn
committed
fix: name wans't const on ex00
1 parent 91d68ae commit 6808c84

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cpp-module-05/ex00/Bureaucrat.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: dpoveda- <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/02/17 12:27:42 by dpoveda- #+# #+# */
9-
/* Updated: 2022/02/18 00:48:49 by dpoveda- ### ########.fr */
9+
/* Updated: 2022/02/20 18:03:57 by dpoveda- ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -28,7 +28,8 @@ Bureaucrat::Bureaucrat(const std::string& name, int grade)
2828
std::cout << "Bureaucrat created" << std::endl;
2929
}
3030

31-
Bureaucrat::Bureaucrat(const Bureaucrat& other) {
31+
Bureaucrat::Bureaucrat(const Bureaucrat& other)
32+
: _name(other._name) {
3233
*this = other;
3334
std::cout << "Copy of bureaucrat created" << std::endl;
3435
}
@@ -38,7 +39,6 @@ Bureaucrat::~Bureaucrat() {
3839
}
3940

4041
Bureaucrat& Bureaucrat::operator=(const Bureaucrat& other) {
41-
this->_name = other._name;
4242
this->_grade = other._grade;
4343
std::cout << "Assignment operator" << std::endl;
4444
return *this;

cpp-module-05/ex00/Bureaucrat.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: dpoveda- <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/02/17 12:12:36 by dpoveda- #+# #+# */
9-
/* Updated: 2022/02/20 14:52:47 by dpoveda- ### ########.fr */
9+
/* Updated: 2022/02/20 18:02:33 by dpoveda- ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -38,7 +38,7 @@ class Bureaucrat {
3838
private:
3939
Bureaucrat();
4040

41-
std::string _name;
41+
const std::string _name;
4242
int _grade;
4343
public:
4444
class GradeTooHighException : public std::exception {

0 commit comments

Comments
 (0)