CPP05 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Bureaucrat.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Bureaucrat.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/06/26 10:32:34 by kamitsui #+# #+# */
9/* Updated: 2025/06/29 06:09:06 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
18#ifndef BUREAUCRAT_HPP
19#define BUREAUCRAT_HPP
20
21#include "Form.hpp"
22#include <iostream>
23#include <stdexcept>
24#include <string>
25
26// Forward declaration of Form to avoid circular dependencies in some cases,
27// though including Form.hpp is necessary here for the signForm method.
28class Form;
29
34class Bureaucrat {
35
36 private:
37 const std::string _name;
38 int _grade;
39 Bureaucrat(); // Private default constructor
40
41 public:
42 // Orthodox Canonical Form
43 Bureaucrat(const std::string &name, int grade);
44 Bureaucrat(const Bureaucrat &other);
47
48 // Getters
49 const std::string &getName() const;
50 int getGrade() const;
51
52 // Member functions
55 void signForm(Form &form);
56
57 // Exception Classes
59 public:
60 virtual const char *what() const throw();
61 };
62
63 class GradeTooLowException : public std::exception {
64 public:
65 virtual const char *what() const throw();
66 };
67};
68
69std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat);
70
71#endif
Defines the Form class and its exceptions.
virtual const char * what() const
virtual const char * what() const
Represents a bureaucrat with a name and a grade.
void incrementGrade()
void decrementGrade()
Bureaucrat(const std::string &name, int grade)
void signForm(Form &form)
Attempts to sign a form. Calls the form's beSigned method and prints the result.
int getGrade() const
Bureaucrat & operator=(const Bureaucrat &other)
const std::string & getName() const
Bureaucrat(const Bureaucrat &other)
Represents a form that needs to be signed and executed.
Definition Form.hpp:32