Explaining copy constructor example-Collection of common programming errors

Print the address of the memory being freed.

I believe you will find the compiler generated the constructor for you, did a value copy of the contents, including the pointer, and you are double-freeing the pointer and just getting lucky that the runtime isn’t complaining about it.

The compiler generated copy constructor is still being called – nothing has changed in that regard, you just aren’t printing anything from it since you didn’t write it.