What do we mean by when we say pointers can have multiple levels of indirection?
![Photo](https://forums.revora.net/uploads/profile/photo-thumb-890936.jpg?_r=1636537450)
Multiple levels of indirection in C++ pointers
#2
Posted 10 November 2021 - 12:38 PM
By this we mean to say that we can have many pointers pointing to each other. A pointer pointing to another pointer is considered as a level of indirection so lets say I have created a pointer a which is pointing to some int temp and now I create a pointer b which is pointing to pointer a so here this is a simple case of indirection where pointer b is not directly pointing towards temp but it points to a which is pointing towards temp, other than indirection pointers have other cool properties and uses most of them discussed by Scaler Topics you can go through these once
Edited by CStrike09, 10 November 2021 - 12:39 PM.
#3
Posted 30 July 2023 - 06:29 PM
In computer programming, a pointer is a variable that stores the address of another variable. This means that a pointer can point to another pointer, which can point to another pointer, and so on. This is called multiple levels of indirection.
For example, let's say we have a variable called x that stores the address of a variable called y. We can then create a pointer called p that stores the address of x. This means that p points to x, which in turn points to y.
C
int x = 10; int *y = &x; int **p = &y;
In this example, p is a pointer to a pointer to an integer. This means that p can be used to indirectly access the value ofx.
Multiple levels of indirection can be used to achieve a variety of programming tasks. For example, they can be used to implement linked lists, trees, and other data structures.Here is a c++ resource that you may find helpful.
Reply to this topic
![](https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=100&d=https%3A%2F%2Fforums.revora.net%2Fpublic%2Fstyle_images%2Frevora2013%2Fprofile%2Fdefault_large.png)
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users