Hi,
I have a question on a smart pointer example given in GCC 4 on page 74 (Chapter 3 Coding Tidbits and Style that Saved Me),
under the section of smart pointer abuses.
The example is:
"The other gotcha is constructing two smart pointers to manage a single object:"
I thought that smart pointers are useful precisely for this purpose.
The z object now has 2 references to it and it will only be destroyed if its reference count drops to 0.
Hence, I am confused why is this considered as a bad practice?
I have a question on a smart pointer example given in GCC 4 on page 74 (Chapter 3 Coding Tidbits and Style that Saved Me),
under the section of smart pointer abuses.
The example is:
"The other gotcha is constructing two smart pointers to manage a single object:"
I thought that smart pointers are useful precisely for this purpose.
The z object now has 2 references to it and it will only be destroyed if its reference count drops to 0.
Hence, I am confused why is this considered as a bad practice?