The code *autodp1
is effectively a dereferencing of a null pointer. Therefore the code exhibits undefined behavior.
You first construct autodp1
to point to the newly allocated double
. But then the constructor of autodp2
takes the owned memory for itself and sets autodp1
to null.