c++ Programming Glossary: shared_ptr
What is a smart pointer and when should I use one? http://stackoverflow.com/questions/106508/what-is-a-smart-pointer-and-when-should-i-use-one the object is deleted. This policy is implemented by boost shared_ptr and std shared_ptr . void f typedef std tr1 shared_ptr MyObject.. This policy is implemented by boost shared_ptr and std shared_ptr . void f typedef std tr1 shared_ptr MyObject MyObjectPtr Nice.. shared_ptr and std shared_ptr . void f typedef std tr1 shared_ptr MyObject MyObjectPtr Nice short alias. MyObjectPtr p1 Empty..
RAII and smart pointers in C++ http://stackoverflow.com/questions/395123/raii-and-smart-pointers-in-c where smart pointers come in. The following example uses shared_ptr I suggest you look at the different types of smart pointers.. of smart pointers to learn what you actually want to use. shared_ptr std string foo shared_ptr std string str new std string Do cool.. what you actually want to use. shared_ptr std string foo shared_ptr std string str new std string Do cool things to or using str..
Which kind of pointer do I use when? http://stackoverflow.com/questions/8706192/which-kind-of-pointer-do-i-use-when std auto_ptr was all the std lib had available and boost shared_ptr was all the rage. I never really looked into the other smart.. c faq share improve this question Shared ownership The shared_ptr and weak_ptr the standard adopted are pretty much the same as.. influencing its lifetime not to break cycles. Cycles with shared_ptr shouldn't normally happen two resources can't own each other...
Why does the use of 'new' cause memory leaks? http://stackoverflow.com/questions/8839943/why-does-the-use-of-new-cause-memory-leaks And then there are some even smarter examples like std shared_ptr that allows multiple pointers to the same object and only cleans..
|