# Whats a Pointer

• 06-30-2007
noobcpp
Whats a Pointer
Thanks To All Today I've understood properly whats Pointer. I was little bit confused about it before
Code:

```Today I've Understood Compleately Whats Pointer "Pointer Is a Special Type Of Variable" First lets Discuss about Some General Variables                 int var = 50; Here a Memory address Say 0xbf45d2c5 has been Alloted for this variable. And in that Location a int Value has been Stored thats 50 and Thats All Now Lets Come To pointer                 int *pVar;                 *pVar = var; "pVar Points to var" Here pVar is a Pointer Variable And value of pVar is the Address of teh Variable named var   (var name)pVar                                    (var name)var        ---------------------                                --------------------- | (value)0xb7d58bf1 |                                |    (value) 50    | ---------------------                                ---------------------        (address) 0x4cf8a7d2e                                (address) 0xb7d58bf1 So pVar is like a tree it holds another variable's Address and that variable holds the value . So how Would we get the value under the pVar (Thats at teh End of the Tree) So as the Value is on depth 1 we need to use                 cout<<*pVar To get teh value of var from pVar Directly So we can call * as a direct access to value Operator or Syntax for this time just to understand Correctly. If pVar Points/holds another pointer variable names say mVar and mVar Points/holds the variable then we need to use                 cout<<**pVar To get the value of var from pvar Directly as teh depth is now 2. If we use *pVar It will just print the Address of var . As the value of mVar is teh Address of var.```
Am I right ??
• 06-30-2007
Salem
An illustration of the relationship between & and * when referring to a pointer variable.
Code:

```#include <iostream> using namespace std; int main( void ) {     int var = 1234;     int *pVar = &var;     cout << reinterpret_cast<void*>(&pVar) << endl;     cout << reinterpret_cast<void*>(pVar) << endl;     cout << *pVar << endl;     return 0; }  Address  Contents         +--------+ 0x22cce0 |0x22cce4| pVar         +--------+ 0x22cce4 |  1234  | var         +--------+```
• 06-30-2007
noobcpp
So was I right ??
• 06-30-2007
Salem
Barring a few syntactic problems, your explanation seems OK.

Though 'pointer to pointer to' is more akin to a list rather than a tree.
• 06-30-2007
noobcpp
K Thanks
But Whats
reinterpret_cast<void*>