add: main, << operator, name in const

This commit is contained in:
Camille Chauvet
2023-08-31 13:26:40 +00:00
parent 68acc04ee8
commit 02d0932e9d
3 changed files with 99 additions and 12 deletions

View File

@ -28,7 +28,6 @@ Bureaucrat::~Bureaucrat()
Bureaucrat& Bureaucrat::operator=(const Bureaucrat &src)
{
this->_name = src._name;
this->_grade = src._grade;
return *this;
@ -43,11 +42,6 @@ void Bureaucrat::setGrade(int new_grade)
this->_grade = new_grade;
}
void Bureaucrat::setName(const std::string &new_name)
{
this->_name = new_name;
}
const std::string& Bureaucrat::getName(void) const
{
return this->_name;
@ -82,8 +76,8 @@ const char* Bureaucrat::GradeTooHighException::what() const throw()
return "Too big grade";
}
std::ostream& Bureaucrat::operator<<(std::ostream &stream)
std::ostream& operator<<(std::ostream &stream, Bureaucrat &src)
{
stream << this->_name << ", bureaucrat grade " << this->_grade << "." << std::endl;
stream << src.getName() << ", bureaucrat grade " << src.getGrade() << "." << std::endl;
return stream;
}