Modern C++ Course [Lecture 8] {Smart/Unique/Shared pointers, Associative containers, Type casting, Enumeration, Binary files}

only use them with heap memory. never ever apply them to stack

 

  

 

 

 

try to avoid using "new and delete" if you can use shared or unique ptr

 

 

 

 delete the a_ptr twice: from } the stack wants to delete a_ptr, from unique_ptr, heap wants to delete a_ptr too.

 

 

be cautious with line 8 comment!!!!!!!!!!!!!

 

 

 https://thispointer.com/map-vs-unordered_map-when-to-choose-one-over-another/

  

 

 

 

 

 

 

ptr (&a) gets adjacted to be a ptr to a single byte type and then this ptr gets next byte, next byte, until it reaches sieof(a)

  

 My own implementation:

 

 results:

猜你喜欢

转载自www.cnblogs.com/ecoflex/p/10212194.html