Welcome! Today, we are going to explore an engaging task that involves managing employee records within a company. Specifically, we will work with nested std::map
and std::vector
to add projects and tasks for employees and retrieve those tasks as needed. This exercise will help you understand how to manipulate nested data structures efficiently in C++.
Let's start by discussing the methods we will implement in our EmployeeRecords
class.
bool add_project(const std::string& employee_id, const std::string& project_name)
- this method adds a new project to an employee's list of projects. If the project already exists for that employee, the method returnsfalse
. Otherwise, it adds the project and returnstrue
.bool add_task(const std::string& employee_id, const std::string& project_name, const std::string& task)
- this method adds a new task to a specified project for an employee. If the project does not exist for that employee, the method returnsfalse
. If the task is added successfully, it returnstrue
.std::vector<std::string> get_tasks(const std::string& employee_id, const std::string& project_name)
- this method retrieves all tasks for a specified project of an employee. If the project does not exist for that employee, the method returns an empty vector. Otherwise, it returns the list of tasks.
