Can someone please explain to me what this class does, and also how to use it?
Printable View
Can someone please explain to me what this class does, and also how to use it?
It's a smart pointer class that handles memory deallocation for you. For rudimentary pointer work, std::auto_ptr is sufficient, but if you want to do anything more useful (such as have containers of smart pointers) the boost library has a smarter smart pointer class. :) Stroustrup 14.4.2 (you do have it, right?) shows you how to use them.
>> Stroustrup 14.4.2 (you do have it, right?)
Nope. In fact, I own no programming books, but that's at the top of my list as soon as I get some money.
number five, page 2
http://gamedev.net/reference/program...dcpp/page2.asp
I just started looking into std::auto_ptrs (which I mentioned in that 3D vector class thread), and boost has many exceptionally good stuff
www.boost.org
EDIT: it makes me upset that there are people out there that look down upon using STL containers and classes. I've actually been criticized for using std::vectors in my own computer game engines because they think I am not l337 enough to write my own home grown containers. I think using stl containers is a good idea, especially for memory management and robustness.
If you get someone who truly says this is foolish, laugh in their face and leave. I think it's a good exercise to write one's own containers at least once, as a means of learning, but I would never be without the STL. It's effective, efficient, and safe.Quote:
Originally posted by Silvercord
EDIT: it makes me upset that there are people out there that look down upon using STL containers and classes. I've actually been criticized for using std::vectors in my own computer game engines because they think I am not l337 enough to write my own home grown containers. I think using stl containers is a good idea, especially for memory management and robustness.
yeah, i've had to write all of that stuff for my C++ class last year in high school (im a senior now), and it's nice to be able to do that stuff, but stl has more work put into it.