Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Aug 2012
Offline Last Active Mar 28 2013 05:07 PM

Topics I've Started

Understanding the concept of Smart Pointers

04 November 2012 - 11:40 AM

The title, likely doesn't do much justice to what my question is, and i'll try to be as a descriptive as I possibly can be.

My issue, is not more on misunderstanding Smart Pointers, but rather, a small glitch in trying to get my head around them. I know smart pointers are used for dynamically creating objects, and that they manage the destruction of these objects, and keep a reference to them using reference counting. But, what I struggle to understand is when I should use these, should I, for example use the std::tr1::shared_ponter<>, for everything.. or just large game sub-systems that need to be referenced by other systems in my game? Such as my graphics rendering system that will need to be used by other parts of my game.. or scene management, etc.. (These are just examples).

Also, where do weak pointers fit into this, when should a weak pointer be used instead of a shared pointer?

I hope my question makes sense, i'll try to clarify anything that doesn't.

and thanks.