Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

http://ideone.com/z2wHp when must I use a raw pointer over a smart pointer in C++?

OpenStudy (anonymous):

Anytime you want to do pointer arithmetic, for example iterate over a buffer to perform indiviual elements, you should just use a raw pointer. Smart pointers are really for avoiding dangling pointers - if for example two objects A and B hold a pointer to a third C, and A releases it, it'll still have a reference from B (B still needs object C). The smart pointer will know this because it counts references in the assignment operator. Only when B releases the pointer will the reference count go to 0, and depending on the smart pointer class, C may be deleted automatically.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!