Hello and welcome to the goal and programming language course in the previous session, we talked about
comparisons with the different values assigned to data fields.
And in this session, we want to talk about the authors abstract concept.
Copyists long time using venue on point to a reference as very ingo learning can be copied to another
variable, easily using the assignment a statement.
Any changes made to the second astronaut will not be reflected back to the first this rocket.
We use two ways to do this.
First copy, boy value and second copy by reference.
Let's go to the school program to illustrate coppinger structure to another variable.
First, we want to talk about concubine value.
Create the astronaut named a student and cis variable for it.
Typekit.
The student just arrived declaring variables name is strange.
All right, marks and.
CC four and said the comment for the export business right to the list.
Now go to the main function,
creating an instance of the student assault type and initialize it for the example.
This to that one column equals the student.
For me, Julia, and for the March 19 display to create an instance if P is to the wrong color.
Student one now calling their strike the student to another variable by using the assignment operator
create an instance named student two and copious student.
Want inside it?
Go to the next line.
The student two color equals the student.
One displayed the created instance if p is student two column student to now list changing values of
a student to his right after copying, for example, the student to thoughts name equals Robert and
the student to dot marks equals ninety five now display to students after changing values.
Go to the next line if be first, set a message this play to the students after changes go to the next
line if P is to that one column, so the student bombarded that and go to the next line.
FP student two column and simply of a student to OK, he formerly called Save the Project and run the
program.
Now we can see the out modifications are applied to the second instance made from the student shrunk,
and no changes are made to the first instance.
And we see a student tool by new values and student y by previous values.
Now, let's go to talk about copy by reference.
First, create a restaurant name person and sets variable for its first clear the last quote
Thai
person extract
declaring variables.
Name a string and I.D. and sixty four said the common or export this is right person construct go to
the main function, creating an instance of the person a stroke type and initialize is for the example
person.
One colon equals person
four named gene and or I.D. one one two two three three display the created instance 50 per cent column
person one.
Now leave Francine this person to another variable by using the Ampersand operator.
Here it is the pointer to the restaurant for the example defined cursor by the named person to go to
the next line.
Person to call and equals Anderson.
Person one displayed the created in response if the person to call in person to.
Now that's changing value of person to a stroke after copy.
For the example, first to the name equals it, go to the next line.
Person two dots I.D. equals four four five five six six now displayed to students after changing values.
First set the message if they display two persons after changing.
Go to the next line.
If the person wrong.
And if the person to reformat the call, save the project and execute the program.
Now we can see the output in this case off point, a reference to the air strike down the line memory
location of the original strike and the pointer to the air strike will be the same.
And it changes made to the second.
The strike will be reflected in the first strike.
Also pointed to a strike is achieved by using the Ampersand operator.
It's allocated on the heat and its arteries is shaved.
OK, in order not to prolong the time of decision, we will finish it and we will continue the content
in the next session.
Goodbye.