1 00:00:01,560 --> 00:00:07,320 Pointers provide a lot of flexibility, but this flexibility comes at safety cost. 2 00:00:07,320 --> 00:00:16,500 So if you don't need the flexibility or risk stability and no VTR references are the go to reference 3 00:00:16,500 --> 00:00:16,920 type. 4 00:00:16,920 --> 00:00:21,440 So let's drive home to the point that references cannot be revisited. 5 00:00:21,450 --> 00:00:28,680 So here we're going to initialize an integer reference in this lecture and then we will attempt to revisit 6 00:00:28,680 --> 00:00:30,960 it with a new value. 7 00:00:31,860 --> 00:00:35,370 So as always, we have to use the include. 8 00:00:35,520 --> 00:00:36,930 We will use the library. 9 00:00:37,080 --> 00:00:37,530 Yes. 10 00:00:37,530 --> 00:00:40,770 Uh, trial here and. 11 00:00:42,050 --> 00:00:46,970 Then we're going to create the original variable and assign to 100. 12 00:00:47,240 --> 00:00:56,390 And if you like, have the problem understanding this course, which as I as I always do, I will explain 13 00:00:56,390 --> 00:00:58,310 after when we write the code. 14 00:00:58,730 --> 00:01:09,200 This is ampersand here, original here, and we're going to assign it to original original here. 15 00:01:09,380 --> 00:01:11,540 And then we will print that. 16 00:01:12,380 --> 00:01:17,440 So remember, we included this system library. 17 00:01:17,450 --> 00:01:18,100 That's why. 18 00:01:18,110 --> 00:01:21,140 Because we need to use the print F here. 19 00:01:21,530 --> 00:01:22,460 So. 20 00:01:26,740 --> 00:01:27,250 Here. 21 00:01:27,280 --> 00:01:35,650 As you can see here, we do not longer have the function print F, So that's why we included this print 22 00:01:36,310 --> 00:01:39,730 this studio library here. 23 00:01:39,730 --> 00:01:41,650 So include it again. 24 00:01:43,350 --> 00:01:43,860 Here. 25 00:01:44,010 --> 00:01:47,400 And as you can see, the our printf function returns. 26 00:01:47,400 --> 00:01:49,860 So, uh, original here. 27 00:01:50,820 --> 00:01:51,210 Yes. 28 00:01:51,810 --> 00:01:54,270 Uh, original here the. 29 00:01:57,320 --> 00:02:01,630 And then we're going to print the original value. 30 00:02:01,640 --> 00:02:06,050 And then let's add another print function here and the reference. 31 00:02:06,940 --> 00:02:07,450 Yes. 32 00:02:12,960 --> 00:02:13,500 Here. 33 00:02:15,720 --> 00:02:16,620 And. 34 00:02:19,500 --> 00:02:22,560 Original that reference, as you can see here. 35 00:02:22,710 --> 00:02:25,470 And then we're going to create a new value. 36 00:02:25,980 --> 00:02:28,610 Name the new value and assign it to 100. 37 00:02:30,590 --> 00:02:31,310 Integer. 38 00:02:31,310 --> 00:02:36,410 New value is assigned to 200 and original ref. 39 00:02:36,440 --> 00:02:38,360 We will use this original ref here. 40 00:02:38,930 --> 00:02:42,830 Original ref equals live value. 41 00:02:43,130 --> 00:02:46,670 And then we're going to print again this here. 42 00:02:46,700 --> 00:02:52,640 As you can see here, we're going to firstly, we're going to print the original, the new value. 43 00:02:52,640 --> 00:02:56,570 And then lastly, we're going to print a reference variable here. 44 00:02:56,840 --> 00:02:58,820 The first is original here. 45 00:03:02,380 --> 00:03:03,600 You know, the. 46 00:03:05,060 --> 00:03:07,160 We're going to pass this original here. 47 00:03:09,420 --> 00:03:12,210 Then we're going to print the original ref. 48 00:03:17,080 --> 00:03:18,490 Or new while you're here. 49 00:03:32,420 --> 00:03:34,190 And lastly, we're going to print the reference. 50 00:03:36,010 --> 00:03:36,420 You're. 51 00:03:38,890 --> 00:03:39,270 Reference. 52 00:03:39,370 --> 00:03:41,200 So and then we're going to. 53 00:03:41,830 --> 00:03:43,600 Here, let me write it. 54 00:03:43,780 --> 00:03:44,160 Okay. 55 00:03:44,610 --> 00:03:45,490 Rough, original. 56 00:03:45,490 --> 00:03:45,760 Rough. 57 00:03:46,450 --> 00:03:47,860 So let's run our code. 58 00:03:51,490 --> 00:03:53,300 And that's our output here. 59 00:03:53,320 --> 00:04:04,810 So now the program here enchilada initializes an integer called Original 200 here. 60 00:04:04,840 --> 00:04:11,000 As you can see here, then it declares a reference to original called Original ref. 61 00:04:11,020 --> 00:04:12,530 Here, as you can see here. 62 00:04:12,550 --> 00:04:19,690 So from this point on, the original ref will always refer to original. 63 00:04:19,720 --> 00:04:21,160 Here, as you can see here. 64 00:04:21,280 --> 00:04:28,270 So this is illustrated by printing the value of original here. 65 00:04:30,550 --> 00:04:33,820 And the value of refer to type original ref. 66 00:04:34,450 --> 00:04:37,750 So as you can see here, we got the hundred here. 67 00:04:38,260 --> 00:04:48,490 Then you'll initialize another integer called new value to 200 and then assign original to it. 68 00:04:49,300 --> 00:04:50,410 As you can see here. 69 00:04:50,920 --> 00:04:51,670 So. 70 00:04:53,190 --> 00:04:53,940 Here. 71 00:04:54,600 --> 00:05:05,520 Read it carefully that the assignment here doesn't receipt original ref so that is points to new value. 72 00:05:05,940 --> 00:05:12,420 Rather, it assigns the value of new value to the object it points to. 73 00:05:12,420 --> 00:05:14,390 That is the original. 74 00:05:14,400 --> 00:05:24,360 So the upshot is that all of these variables, original original ref and new value evaluate 200 after 75 00:05:24,360 --> 00:05:25,680 this code here.