diff --git a/ex00/inc/Bureaucrat.hpp b/ex00/inc/Bureaucrat.hpp index 72cf55d..9e4c7f5 100644 --- a/ex00/inc/Bureaucrat.hpp +++ b/ex00/inc/Bureaucrat.hpp @@ -2,6 +2,7 @@ #include #include +#include #define HIGHEST_GRADE 1 #define LOWEST_GRADE 150 @@ -38,3 +39,5 @@ public: const char *what() const throw(); }; }; + +std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat); \ No newline at end of file diff --git a/ex00/src/Bureaucrat.cpp b/ex00/src/Bureaucrat.cpp index 52c3d35..6349119 100644 --- a/ex00/src/Bureaucrat.cpp +++ b/ex00/src/Bureaucrat.cpp @@ -87,4 +87,10 @@ const char * Bureaucrat::GradeTooHighException::what() const throw() const char * Bureaucrat::GradeTooLowException::what() const throw() { return "Grade too low!"; -} \ No newline at end of file +} + +std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) +{ + std::cout << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade(); + return os; +} diff --git a/ex00/src/main.cpp b/ex00/src/main.cpp index f81c232..e3e9fe2 100644 --- a/ex00/src/main.cpp +++ b/ex00/src/main.cpp @@ -15,6 +15,7 @@ int main (void) { std::cerr << "Caught exception: " << e.what() << std::endl; } + try { Bureaucrat alice("alice", 151); // This should also throw an exception @@ -23,6 +24,7 @@ int main (void) { std::cerr << "Caught exception: " << e.what() << std::endl; } + try { Bureaucrat charlie("charlie", 1); @@ -32,6 +34,7 @@ int main (void) { std::cerr << "Caught exception: " << e.what() << std::endl; } - + std::cout << jan << std::endl; + std::cout << copy << std::endl; }