Hello and welcome to the goal and programming language course in this session, we want to talk about
the either added concepts.
Copy on at eight by value and reference into another.
You can create a copy of an array by assigning NRA to a new very bill, either by value or reference.
First value, then we assign the value of one validated in another value, then changing the first value
that does not change the second variable because the value of the first value that is copied to the
second variable, which is called the value second reference.
But then we assigned the address of one lady that in another variable changing the value of the first
that he had been honest to change the value of the second lady that it is called reference.
Now, go to this school and illustrate how to use to copy him at a boy venue and reference into an already.
First, define and add and initialize eat, for example, at a long calling equals this global markets
sit three for the length tied a string and curly brackets for initialize
Team
Dean
and be.
So create an array and copy at Avon into this in the next line.
Ray two calling equals and copy anyone to eat.
I want data is passed by value.
Now define another variable and copy anyone into this array.
Three content equals and copy the address of the variable at Avon into this and array one.
In this case, data is passed by a reference if we want to pass a reference value we use from ampersand
symbol before the variable.
Now display at Avon and added to if it
at a long balance percent v lowercase legislation and sets only one, then
it has
a two tolerance person to lowercase registers and and sets I to say inclusion and continue.
Now we change the index zero five at Avon Valley Bin and print on Vati.
Even again, do the following Add a long list of broadcast and index zero and we change the venue of
it to.
For the example, Alex
now display all the variables for these.
Copied these two lines
and paste here
for display the pointer variables we use from star symbol before variable name.
So for print the variable ADT, we use this code.
If if
at a tree pollens person to the lower case
and sets the star add a tree, the format, the cool, save the project and execute the code.
Now we can see the output in the first variable.
We have changed index zero value.
When you print it, the first variable is printed with the new menu in the second.
Very bad because the value of the first variable is copied inside it, or in other words, data is passed
by value.
So no change will be made in the second variable, but in the third variable, because the address of
the first variable is assigned in the third variable or in other wars.
Data is passed by reference.
The value of the first element of the third variable will also change and the third variable will be
printed within nil value.
Now we could copy and Ari by venue and reference into another area in order not to prolong the time
of decision.
We will finish it and we will continue the content in the next session.
Goodbye.