Reference types, stored memory addresses of the objects.
So these types enable efficient programming and many elegant design patterns feature them.
So in this lecture, I will discuss the two kinds of reference types, the pointers and the references.
I will also discuss this, this keyword keyword here and auto auto keyword along the way.
So let's get started by the pointers.
So pointers.
Are the fundamental mechanism used to refer to memory addresses.
So pointers encode both pieces of information required to interact with another object.
So that is the object address and the object type.
So you can declare a pointer by type by appending an asterisk to the pointer to type.
Here.
Here, for example, my p.
T.
R.
So the format specified for the pointer is this p here.
So for example, to print a value in my TR, you could use this kind of code here.
So the value of my TR, the value of my Peter is p.
This is a format specified for pointer here and my p t are here.
And let's run this here.
And as you can see here, the value of my TR is zeros here.
So the pointers are very low level objects, although they play a central role in most C programs.
So C++ offers higher level, sometimes more efficient constructs that obviate the need to deal with
the memory addresses directly.
So monthlies pointers are foundational concepts that you will know that come across in your system.
Programming travels.
So in this section of our course, you will learn how to find the address of an object and how to assign
the result to a pointer variable.
So you will also learn how to perform the opposite operation, which is called the DE referencing.
So the reference means given a pointer, you can obtain the object residing at the corresponding address
so you will know more about race.
So the simplest construct for measuring an object collection as well as how arrays relate to pointers.
So as low level constructs, arrays and pointers are relatively dangerous.
So you will learn about what can go wrong when pointer and arrays based programs go angry.
So this lecture introduced two special kinds of pointers.
The first is void pointers and the first is void pointers and STD STD byte pointers.
So these are very useful, useful types.
They have some special behaviors that you will need to keep in mind.
Additionally, you will learn how to encode empty pointers with new p tr and how to use in boolean expressions
to determine whether they are empty or not.
So let's get started by addressing variables in C++ pointers so you can obtain the address of variables
by pretending the address of operator.
Actually, I want to note that.
So you will keep in mind that operator operator and operand names in this programming languages.
So this is the address of operator.
Address of operator.
So you might want to use this operator to initialize the pointer so it points to the corresponding variable.
Such programming requirements arise very often in operating system programming.
So for example, major operating system such as Windows, Linux and Free BSD have interfaces that use
pointers here heavily.
So now let's get to the practice practical programming in our course.
So integer my pointer here I will all just for example, my variable here my variable.
So here we will create my variable with this, which I will explain our course later as I do always.
So my variable here.
Your my variable.
Uh, the integer.
My variable address.
My variable.
And then print off.
Yes.
New line.
My variable address.
Here.
So now I will tell you what.
These codes are so v Firstly, you declare that integer my variable and print its value.
So then you declare a pointer called my variable address to that integers address.
As you can see here, we use the address of operator.
So notice that the asset square presents the pointer and ampersand pretends the my variable here.
So finally you point to the pointer to the screen here to reveal the my variable address.
Let's print this out.
And as you can see here, we got the mind variable equal to zero.
And my variable address is this here.
This is the this is where my variable variable resides and lives in our memory, random access memory.
So your output should have an identical value, as you can see here.
But my variable address should be different each time, as you can see here.
So this variation is due to the address space layout randomization, which is a security feature that
scrambles the base address of important memory regions to hamper exploitation.