I\'ve seen some code, as well as some errors generated from my compiler that have a \'**
\' token before the variable (eg **variablename unreferenced-- or someth
It's a double dereference.
int i = 3;
int* ptr_to_i = &i;
int** ptr_to_ptr_to_i = &ptr_to_i;
std::cout << **ptr_to_ptr_to_i << std::endl;
Prints 3.
You may recognize the signature for main():
int main(int argc, char* argv[])
The following is equivalent:
int main(int argc, char** argv)
In this case, argv is a pointer to an array of char*.
In C, the index operator [] is just another way of performing pointer arithmetic. For example,
foo[i]
produces the same code as
*(foo + i)
int **var
declares a pointer to a pointer **var
references the content of a pointer, which in itself points to a pointerIt's not a **
token. It's simply a *
token followed by another *
token. In your case, you have a pointer to a pointer, and it's being dereferenced twice to get whatever's really being pointed to.
See http://www.c2.com/cgi/wiki?ThreeStarProgrammer