1
00:00:03,660 --> 00:00:06,230
Signs were covering the use of variables.

2
00:00:06,240 --> 00:00:12,510
It's worth explaining the syntax used to define pointers and arrays because there are some potential

3
00:00:12,510 --> 00:00:13,310
pitfalls.

4
00:00:13,320 --> 00:00:20,310
So working with memory arrays and pointers covers in the in next lectures in more detail.

5
00:00:20,310 --> 00:00:24,880
So we will just introduce this syntax so that you are familiar with it.

6
00:00:24,900 --> 00:00:30,360
So in C plus plus you will access memory used a typed pointer.

7
00:00:30,870 --> 00:00:37,490
So the type indicates the type of the data that is held in the memory that is pointed to.

8
00:00:37,500 --> 00:00:44,550
So if the pointer is an four byte integer pointer, it will point to four bytes that can be used as

9
00:00:44,550 --> 00:00:45,420
an integer.

10
00:00:45,420 --> 00:00:52,830
If the integer pointer is incremented, then it will point to the next four bytes which can be used

11
00:00:52,830 --> 00:00:54,450
as an integer.

12
00:00:54,630 --> 00:01:00,120
So in C plus plus pointers are declared using the asterisk here.

13
00:01:00,120 --> 00:01:01,050
Asterisk.

14
00:01:03,250 --> 00:01:10,210
Using this asterisk symbol and you access a memory address with this and operand.

15
00:01:10,750 --> 00:01:24,730
So let's create a pointer P here, integer E 52 and P equals and operator and a symbol here.

16
00:01:24,730 --> 00:01:32,350
And so now I want to explain and comment these lines so you can when you download these codes, you

17
00:01:32,350 --> 00:01:36,430
got understanding of what these lines means.

18
00:01:37,160 --> 00:01:47,060
So the first line declares a variable P, which will be used will be used to hold the memory address

19
00:01:47,060 --> 00:01:48,920
of an integer.

20
00:01:50,090 --> 00:01:53,210
So the next one here.

21
00:01:55,200 --> 00:01:55,740
Um.

22
00:01:55,740 --> 00:02:07,920
The second line declares an integer, declare declares and an integer and signs value.

23
00:02:08,400 --> 00:02:16,140
As you remember, this is just a usual usual thing that how we declare the integer values here?

24
00:02:16,290 --> 00:02:17,550
Nothing strange here.

25
00:02:17,580 --> 00:02:19,740
Nothing new here for, uh.

26
00:02:19,740 --> 00:02:20,310
For us.

27
00:02:20,310 --> 00:02:22,200
Here and here.

28
00:02:22,200 --> 00:02:24,990
As you can see, we used the and operator.

29
00:02:24,990 --> 00:02:26,520
So this.

30
00:02:26,550 --> 00:02:27,100
And operator.

31
00:02:27,120 --> 00:02:29,370
The third line assigns a value.

32
00:02:29,580 --> 00:02:32,970
Assigns a value.

33
00:02:34,140 --> 00:02:35,520
Assigns a value.

34
00:02:35,520 --> 00:02:44,340
So this assigns a value to the pointer P here.

35
00:02:45,230 --> 00:02:47,900
Uh, to be the address.

36
00:02:48,930 --> 00:02:51,240
Of the integer.

37
00:02:52,120 --> 00:02:52,930
Variable.

38
00:02:54,760 --> 00:02:55,180
Here.

39
00:02:55,360 --> 00:03:02,590
So it's important to stress that the value of P is not 52.

40
00:03:03,340 --> 00:03:07,060
It will be a memory address where the value of 52 is stored.

41
00:03:08,160 --> 00:03:14,880
So note how the declaration has the asterisk here on the variable name.

42
00:03:14,880 --> 00:03:21,690
This is a common convention that the reason is that if you declare a several variables on in one statement,

43
00:03:22,410 --> 00:03:26,700
the asterisk here applies only to the immediate variables.

44
00:03:26,700 --> 00:03:34,680
So for example, let's create an integer, uh, integer P1, p2, P3 here.

45
00:03:35,070 --> 00:03:40,470
So as you can see here, this is the example of this is a common convention.

46
00:03:40,680 --> 00:03:46,770
The reason is that if you declare a several variables in one statement, this asterisk applies only

47
00:03:46,770 --> 00:03:49,860
to the immediate immediate variable.

48
00:03:50,040 --> 00:03:55,890
And let's create another example of the declaring pointer types here.

49
00:03:55,890 --> 00:04:03,600
So this looks like you're declaring here as you as you can see, let's make here integer.

50
00:04:03,870 --> 00:04:08,230
This will look like you are declaring two integer pointers.

51
00:04:08,410 --> 00:04:10,930
However, this line does not do this here.

52
00:04:11,500 --> 00:04:12,090
Um.

53
00:04:12,130 --> 00:04:14,170
Integer P1.

54
00:04:15,060 --> 00:04:16,980
An integer P two.

55
00:04:17,370 --> 00:04:21,420
Actually, we did the P one integer.

56
00:04:21,480 --> 00:04:22,320
S one.

57
00:04:23,500 --> 00:04:25,090
Integer S2.

58
00:04:25,970 --> 00:04:26,540
Here.

59
00:04:27,080 --> 00:04:28,160
So.

60
00:04:29,200 --> 00:04:30,210
As you can see.

61
00:04:30,310 --> 00:04:31,350
See here?

62
00:04:31,790 --> 00:04:32,180
Um.

63
00:04:33,090 --> 00:04:35,130
This line does not do this.

64
00:04:35,160 --> 00:04:38,520
As you can see, we have three pointers here, pointer, two types here.

65
00:04:38,520 --> 00:04:46,230
And this line does not do this, does this because the second variable is an integer called P called

66
00:04:46,230 --> 00:04:55,710
S2 and it declares just one pointer called the integer called S1 integer pointer here.

67
00:04:55,890 --> 00:05:06,030
And if you wish to declare the two integers in one statement, then you should do as follows.

68
00:05:06,030 --> 00:05:06,390
Here.

69
00:05:06,420 --> 00:05:09,270
P1 and.

70
00:05:12,290 --> 00:05:14,090
T1 and.

71
00:05:16,020 --> 00:05:17,520
T two.

72
00:05:17,910 --> 00:05:28,140
So this is the correct one if you want if you want to declare two pointers to pointer types here.
