WEBVTT

00:01.180 --> 00:09.250
So the next step is to iterate the list from the first link, following each next pointer until we get

00:09.250 --> 00:10.640
to the end of the list.

00:10.660 --> 00:14.940
So for each link access the task should be executed here.

00:14.950 --> 00:22.390
So start by writing a function that performs the execution, by printing out the description of the

00:22.390 --> 00:26.690
task and then returning the pointer to the next task.

00:26.710 --> 00:34.450
So here, just above the main function, we're going to add the task that we're going to add the function

00:35.230 --> 00:39.460
that will return the task here and execute this.

00:40.000 --> 00:49.390
This function will be named at execute task in a constant task pointer P task.

00:49.840 --> 00:51.130
So here.

00:53.240 --> 00:56.540
The if the nullptr nullptr.

00:57.590 --> 00:59.090
Equals to P task.

00:59.810 --> 01:02.430
Then return the nullptr.

01:03.760 --> 01:08.230
See out here executing the.

01:09.260 --> 01:12.620
Finally, we've writing some outputs here.

01:15.690 --> 01:16.260
Here.

01:19.570 --> 01:21.460
And task.

01:22.580 --> 01:25.340
This operator here and description.

01:26.870 --> 01:28.580
And of course, in line here.

01:30.420 --> 01:32.650
And we're going to return the task object.

01:32.700 --> 01:33.360
A task?

01:33.390 --> 01:35.070
Uh, not object task.

01:35.460 --> 01:39.510
The struct here, as you can see here, return the task.

01:39.510 --> 01:40.570
P task.

01:40.840 --> 01:45.510
Task and p p next.

01:46.080 --> 01:54.060
So the parameter here is marked as constant because we will not change the task object pointed to by

01:54.060 --> 01:54.660
the pointer.

01:54.660 --> 02:00.300
So this indicates that the compiler that if the code does try to change the object, there is an usually

02:00.300 --> 02:07.170
here the first line checks to make sure that the function is not called with the null pointer.

02:07.170 --> 02:09.240
So it was done following line.

02:09.270 --> 02:15.390
Would the reference invalid pointer and cause a memory access fault?

02:15.390 --> 02:22.290
So the last line returns the pointer to the next link, which could be nullptr for the last link in

02:22.290 --> 02:26.640
the list so that the function can be called in loop.

02:26.640 --> 02:28.620
So after this function.

02:29.620 --> 02:32.900
We're going to add another function here.

02:32.920 --> 02:36.220
Void function named execute all.

02:36.880 --> 02:39.550
So here task.

02:41.310 --> 02:42.540
Task here.

02:43.170 --> 02:44.040
The task.

02:46.240 --> 02:47.710
And P hat.

02:49.210 --> 02:49.690
What's.

02:50.650 --> 02:52.630
The task assigned to p hat.

02:53.140 --> 03:00.580
And while the p task is not equal to nullptr, PTA is not equal to nullptr.

03:01.550 --> 03:01.970
Here.

03:02.960 --> 03:05.270
We're going to assign task.

03:06.760 --> 03:12.460
Execute task and we're going to pass the p task itself here.

03:12.460 --> 03:15.790
So this code starts at beginning.

03:16.140 --> 03:25.430
Uh, p hat and calls the execute task on each list in the list until the function returns the nullptr.

03:25.450 --> 03:32.110
So we're going to add the call function towards the end of the main function here.

03:32.980 --> 03:33.760
Okay.

03:36.210 --> 03:43.220
Going to first execute all function and execute all function, and we're going to call the destroy.

03:44.290 --> 03:46.110
Destroy a okay.

03:46.990 --> 03:47.560
Yeah.

03:48.220 --> 03:49.900
Make it upper.

03:51.480 --> 03:51.870
Go here.

03:51.870 --> 04:00.960
We're going to call destroy list function here so we can now compile and run our code.

04:00.960 --> 04:05.730
But we have a okay, we can now compile and run the code here.

04:10.330 --> 04:12.010
The result will be like this.

04:12.010 --> 04:21.550
But in this here, in this lecture, we're going to add another, uh, items here in this struct here

04:21.550 --> 04:26.170
and make it more, uh, rich with objects here.

04:26.170 --> 04:31.330
So in next lecture we're going to add the items, insert items to the struct.
