Pointers provide a lot of flexibility, but this flexibility comes at safety cost.
So if you don't need the flexibility or risk stability and no VTR references are the go to reference
type.
So let's drive home to the point that references cannot be revisited.
So here we're going to initialize an integer reference in this lecture and then we will attempt to revisit
it with a new value.
So as always, we have to use the include.
We will use the library.
Yes.
Uh, trial here and.
Then we're going to create the original variable and assign to 100.
And if you like, have the problem understanding this course, which as I as I always do, I will explain
after when we write the code.
This is ampersand here, original here, and we're going to assign it to original original here.
And then we will print that.
So remember, we included this system library.
That's why.
Because we need to use the print F here.
So.
Here.
As you can see here, we do not longer have the function print F, So that's why we included this print
this studio library here.
So include it again.
Here.
And as you can see, the our printf function returns.
So, uh, original here.
Yes.
Uh, original here the.
And then we're going to print the original value.
And then let's add another print function here and the reference.
Yes.
Here.
And.
Original that reference, as you can see here.
And then we're going to create a new value.
Name the new value and assign it to 100.
Integer.
New value is assigned to 200 and original ref.
We will use this original ref here.
Original ref equals live value.
And then we're going to print again this here.
As you can see here, we're going to firstly, we're going to print the original, the new value.
And then lastly, we're going to print a reference variable here.
The first is original here.
You know, the.
We're going to pass this original here.
Then we're going to print the original ref.
Or new while you're here.
And lastly, we're going to print the reference.
You're.
Reference.
So and then we're going to.
Here, let me write it.
Okay.
Rough, original.
Rough.
So let's run our code.
And that's our output here.
So now the program here enchilada initializes an integer called Original 200 here.
As you can see here, then it declares a reference to original called Original ref.
Here, as you can see here.
So from this point on, the original ref will always refer to original.
Here, as you can see here.
So this is illustrated by printing the value of original here.
And the value of refer to type original ref.
So as you can see here, we got the hundred here.
Then you'll initialize another integer called new value to 200 and then assign original to it.
As you can see here.
So.
Here.
Read it carefully that the assignment here doesn't receipt original ref so that is points to new value.
Rather, it assigns the value of new value to the object it points to.
That is the original.
So the upshot is that all of these variables, original original ref and new value evaluate 200 after
this code here.