c++ - linked list memory management -


How can I freeze a linked list that contains dynamic allocated objects? I list & lt; Class * & gt; Try to use the list, but then I could not use the insert () function to insert the object in the list. Does anyone know what the reason is?

std :: list & lt; Boost :: shared_ptr & lt; YourType & gt; & Gt; will automatically call YourType :: ~ YourType on each (smart) pointer in the list, when the list will be deleted. And if you delete a list element, then it will call YourType :: ~ YourType for an element. You can still call list.insert (new YourType )

link:


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -