December 2018
Intermediate to advanced
702 pages
20h 9m
English
The next thing to do to provide the code is to add a new task to the task list. This needs to create a new task object and initialize it appropriately and then add it to the list by altering the last link in the list to point to the new link.
Above the main function, add the following function:
void queue_task(const string& name) { ... }
The parameter is a const reference because we will not change the parameter and we do not want the overhead of a copy being made. The first thing this function must do is create a new link, so add the following lines:
void queue_task(const string& name) { task* pTask = new task; pTask->description = name; pTask->pNext = nullptr; }
The first line creates a new link ...
Read now
Unlock full access