I just learn about pointer in C++ and I'm confused with the usage of pointer when it comes to int* (with 1 asterisk) and int** (with 2 asterisk). Can anyone explain why I should use both of them and the usage?
Asked
Active
Viewed 39 times
0
-
That's a [double pointer](https://www.geeksforgeeks.org/double-pointer-pointer-pointer-c/). – Libra Nov 09 '21 at 01:48
-
`int i` declares `i` as a variable of type `int` (i.e. its value is integral). `int *p` declares `p` as a variable who's value is the address of an `int`. `p` can be assigned a value which is the address of an `int`, such as `p = &i`. `int **p2` declares `p2` as a variable who's value is the address of an `int *`. Similarly `p2` can be store the address of an `int *`, such as `p2 = &p`. – Peter Nov 09 '21 at 03:31