A dynamic array looks something kind of like this:
struct DynamicArray(T)
{
size_t length;
T* ptr;
}
So, if you take the address of a dynamic array, you're
basically taking the address of a struct on the stack, whereas
the address in ptr is the address in memory where the data is
(be it GC-allocated memory, malloc-ed memory, or a static array
on the stack somewhere).
Similarly, if you have a class reference, and you take its
address, you're taking the address of the reference, not the
class object that it points to. e.g.
class MyClass
{
string foo;
}
MyClass mc;
auto addr = &mc;
addr is the address of mc on the stack, whereas mc itself is
null.
- Jonathan M Davis
Many thanks for your speedy and clear answer Jonathan! That makes
even sense to me :-)