Interesting article, but I'm afraid your comments about C++ are not technically accurate:
In C++ when a variable is created the variable has an address of 0xddddddd (in debug but it can be different non-real addresses as well). When you set the variable the first time checking the address will give you a valid memory address where the data is being stored.
It can be easily proven that this is not the case. In C++ a variable has both an address and storage space upon declaration. In debug mode that storage is initialized with a distinctive pattern (such as 0xdd, depending on compiler version.) In release mode, it will contain whatever random garbage happened to be in memory.
This is true of both pointer types and non pointer types (in the strictest sense) though pointer types require a bit more explanation: A pointer type, as its name suggests, is a variable that stores an address that points to something else.
When a pointer is declared, it is true that no memory has been allocated to store anything of the type it points to
, that space must be separately allocated, and its address is assigned to the pointer. Even so, at declaration a pointer type does have an address of it's own, and enough memory to store a pointer
has been allocated for it.
int i; // sizeof(int) bytes allocated on the stack
int *p; // size of a memory address allocated on the stack
cout << i << endl; // garbage value
cout << (int)&i << endl; // valid mem location
cout << (int)p << endl; // garbage value
cout << *p << endl; // access fault! can't dereference invalid location
cout << (int)&p << endl; // valid mem location (double indirection)
p = &i; // storage for an int now assigned to pointer
cout << *p << endl; // value is still garbage, but valid to defererence
*p = 1; // assigning value to mem pointed to
cout << i << endl; // pop quiz: what will this output be? :-)
The Black Knight ALWAYS triumphs. Have at you!