Smart pointer (different between ~ auto_ptr () and release ())

I would like to know different functions ~auto_ptr()and release().

Are they the same method, or are there differences between erasing and freeing memory?

+3
source share
2 answers

auto_ptr :: Release ()

Sets the auto_ptr internal pointer to a null pointer (which indicates that it indicates the absence of an object) without destroying the object that auto_ptr is currently pointing to. It returns the value of the internal pointer before it was set to null. After the call release() auto_ptr, you can still point to another object.

auto_ptr :: ~ auto_ptr ()

, " ", delete .\ ~auto_ptr() auto_ptr .

+8

Ehm... , , .
, , release , .
~auto_ptr , - undefined.

+3

All Articles