In addition to having a pointer that points to a number or a character, etc., pointers can point to other pointers. A commonly used example is an array of pointers, since the array name points to the elements in the array, then each element can contain a pointer to the data.
- [Instructor] In addition to having a pointer…that points to a number or a character, etc.,…pointers can point to other pointers.…This can definitely be a little confusing,…so, let's start with an example.…In your Exercise Files folder, under Chapter 2,…02_04, I have a program that, in the main method, here,…starting on line 11, I'm declaring…an integer variable, num = 10, just a random value.…Now, on line 12, I'm creating a pointer.…So, I create int* pNum is equal to, using the ampersand,…to get the address of, the num variable.…
So, now, I'm putting the address of…the variable num, into pNum.…Now, what I can do, is, I can make…another pointer, that points to a pointer.…So, I have to use int** and I called this one p2Num…and it's equal to the address of…the pointer, that points to num.…All right, so, let's see what's happening here, first,…and then we'll talk a little bit more about use cases.…In order to see what's happening,…let's print out some of the values, here.…Let's start with printing out the Address of num.…
- Addresses vs. pointers
- Understanding the relationship between pointers and arrays
- Dereferencing pointers
- Passing pointers as arguments
- Using new and delete operators