Let's go through your code line by line.
First, you created a Point
called p
. So p
is sitting in the memory somewhere:
Memory: p:[x, y]
Then, you created a Disk
called d
, which stores it's own Point
object inside it.
Memory: p:[x, y] d:[center:[x, y], radius]
These are completely separate objects. When you modify the Point
stored in d
with d.center.x=1.2
, it does not affect p
at all.
Therefore, p
is uninitialized, and reading the value of uninitialized variables causes undefined behavior, meaning anything can happen, in this case usually getting a random value.