Thanks To All Today I've understood properly whats Pointer. I was little bit confused about it before
Am I right ??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.



LinkBack URL
About LinkBacks


