So the next step is to iterate the list from the first link, following each next pointer until we get
to the end of the list.
So for each link access the task should be executed here.
So start by writing a function that performs the execution, by printing out the description of the
task and then returning the pointer to the next task.
So here, just above the main function, we're going to add the task that we're going to add the function
that will return the task here and execute this.
This function will be named at execute task in a constant task pointer P task.
So here.
The if the nullptr nullptr.
Equals to P task.
Then return the nullptr.
See out here executing the.
Finally, we've writing some outputs here.
Here.
And task.
This operator here and description.
And of course, in line here.
And we're going to return the task object.
A task?
Uh, not object task.
The struct here, as you can see here, return the task.
P task.
Task and p p next.
So the parameter here is marked as constant because we will not change the task object pointed to by
the pointer.
So this indicates that the compiler that if the code does try to change the object, there is an usually
here the first line checks to make sure that the function is not called with the null pointer.
So it was done following line.
Would the reference invalid pointer and cause a memory access fault?
So the last line returns the pointer to the next link, which could be nullptr for the last link in
the list so that the function can be called in loop.
So after this function.
We're going to add another function here.
Void function named execute all.
So here task.
Task here.
The task.
And P hat.
What's.
The task assigned to p hat.
And while the p task is not equal to nullptr, PTA is not equal to nullptr.
Here.
We're going to assign task.
Execute task and we're going to pass the p task itself here.
So this code starts at beginning.
Uh, p hat and calls the execute task on each list in the list until the function returns the nullptr.
So we're going to add the call function towards the end of the main function here.
Okay.
Going to first execute all function and execute all function, and we're going to call the destroy.
Destroy a okay.
Yeah.
Make it upper.
Go here.
We're going to call destroy list function here so we can now compile and run our code.
But we have a okay, we can now compile and run the code here.
The result will be like this.
But in this here, in this lecture, we're going to add another, uh, items here in this struct here
and make it more, uh, rich with objects here.
So in next lecture we're going to add the items, insert items to the struct.