Reference types store the 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 const 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 pointers by type by appending an asterisk to the pointer to type here.
Here, for example, my pointer.
So the format specifier for the pointer is this P here.
So for example, to print the value in my TR, you could use this kind of code here.
So the value of my p tr, the value of my p tr is P, it is a format specifier for pointer here and
my p tr here.
And let's run this here.
And as you can see here, the value of my P is zero here.
So the pointers are very low level objects, although they play a central role in most C programs.
So C plus plus of offers, high level, sometimes more efficient constructs that obviate the need to
deal with the memory addresses directly.
So nonetheless, pointers are foundational concepts that you will no doubt 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 Dereferencing.
So the dereferencing means given a pointer you can obtain the object residing at the corresponding address,
so you will learn more about race.
So the simplest construct for managing 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, um, some special behaviors that you will need to keep in mind.
Additionally, you will learn how to encode empty pointers with nullptr and how to use in boolean expressions
to determine whether they are empty or not.
So let's get started by the addressing variables in C plus plus pointers so you can obtain the address
of variables by prepending.
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 a 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 FreeBSD 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 or just for example, my variable here, my variable.
So here we will create my variable with this, which I will explain our codes later as I do always.
So my variable here.
Here.
My variable and integer.
My variable address.
My variable here.
And then print f.
Here.
New line.
My variable address.
Here.
So now I will tell you what.
These chords are.
So we firstly you declare the integer my variable and print its value.
So then you declare a pointer called my variable address to that integer address.
As you can see here, we use the address of operator.
So notice that the asterisk here prepends 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 myvariable equals to zero.
And my variable address is this here.
This is the, uh, this is where my variable, uh, variable, uh, resides and lives in our memory.
Random access memory.
So, uh, 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.