WEBVTT

00:00.690 --> 00:04.860
The Konski word doesn't just apply to normal variables.

00:04.930 --> 00:08.070
You can also use it with pointers and references.

00:08.130 --> 00:20.060
So for example you'd have a pointer to an integer constant like this since say x x 5 and you like something

00:20.060 --> 00:29.950
like this star will say X don't dare calls to X like that.

00:31.750 --> 00:35.430
OK so x pointer points to x.

00:35.430 --> 00:40.700
Now however it can't change the value of x K.

00:40.910 --> 00:44.360
So I can't do something like this

00:47.000 --> 00:47.880
anymore.

00:49.040 --> 01:03.240
Even if we try right it says error read only variable is not assignable So go as read only now.

01:04.010 --> 01:07.680
That means.

01:07.760 --> 01:15.620
So while I can't change the value of what it wants to I can change where it points to.

01:15.770 --> 01:20.060
So I could do something like this.

01:20.630 --> 01:23.520
And why.

01:23.600 --> 01:34.160
And I can do this calls to my.

01:34.390 --> 01:35.700
So that worked.

01:35.710 --> 01:42.920
In fact if I print out the value X pointer value is

01:46.550 --> 01:47.110
ptr

01:51.640 --> 01:52.560
to 50.

01:52.590 --> 01:53.070
Right.

01:53.220 --> 01:56.860
So it's the Y variable.

01:56.910 --> 01:57.210
Now

02:00.350 --> 02:08.050
so and of course I can't change that y variable the variables value.

02:08.880 --> 02:17.190
I can do the complete opposite as well and create a pointer that can change the value but it points

02:17.190 --> 02:24.310
do but not change where points so I can do something like this.

02:24.510 --> 02:26.480
Come in.

02:27.800 --> 02:33.230
Store say Conte's here.

02:34.560 --> 02:46.990
And I'll say Why enter K will give it y it's this.

02:47.050 --> 02:47.340
Now

02:52.310 --> 03:00.960
so if I try to change where y pointer points to

03:03.460 --> 03:04.120
that

03:06.960 --> 03:09.600
try this.

03:09.630 --> 03:10.920
So there you go.

03:10.950 --> 03:15.570
It doesn't I can't change to where it points to

03:19.140 --> 03:29.820
some numbers here that I must set something on on the on the pointer.

03:29.890 --> 03:34.670
So right here I have to set up this here.

03:34.880 --> 03:38.980
And notice also that I can change the value of.

03:40.430 --> 03:43.430
Y going to air.

03:43.760 --> 03:48.920
I mean that's a fire and that's it works.

03:49.050 --> 03:51.030
Doesn't complain to me.

03:51.030 --> 03:51.910
OK.

03:52.620 --> 03:57.510
So we call this a constant pointer.

03:57.510 --> 04:01.920
This one here is effectively like a reference.

04:01.920 --> 04:09.600
In fact it can change what if it can't change what it points to but it can change the value of what

04:09.600 --> 04:18.360
it points to and it is complete opposite of this which can't change the value that it points to but

04:18.360 --> 04:22.080
it can change where points to.

04:22.650 --> 04:33.780
So I always try to read these from left or right to left because that kind of helps me understand how

04:33.780 --> 04:34.960
it works.

04:34.990 --> 04:50.630
So this one is a pointer to an integer constant k and this one is a constant to a pointer that has type

04:50.690 --> 04:56.500
integer k so this is a constant pointer to an integer.

04:59.170 --> 05:05.750
So like I said before the references are basically constant pointers.

05:06.020 --> 05:10.060
So you could do something like this.

05:14.420 --> 05:15.240
Streff

05:19.580 --> 05:33.070
goes to X this ERPs X that k means I can't change where it points to or change its value.

05:33.070 --> 05:33.520
Right.

05:35.780 --> 05:40.610
Because now before references could change the value of X.

05:40.670 --> 05:44.980
However now I can't do that because now it's constant.

05:45.320 --> 05:52.460
K and of course as a pointer this would be like this.

05:55.840 --> 05:58.350
An X pointer to a

06:06.320 --> 06:13.870
these are effectively equivalent terms of what they can and can't do.

06:14.360 --> 06:18.450
So I am using these facts in the next lecture.
