The first one creates a default-constructed temporary object, and uses the the copy-constructor (if the assignment is in the declaration of A
) or the copy-assignment operator to copy from the temporary object to A
. Then the temporary object is destroyed.
The second creates a default-constructed object on the heap, and returns a pointer to this new object. You must later delete
this object or you will have a memory leak.