What wrapper class in C++ should I use for automated resource management?

前端 未结 8 1118
余生分开走
余生分开走 2020-12-16 13:56

I\'m a C++ amateur. I\'m writing some Win32 API code and there are handles and weirdly compositely allocated objects aplenty. So I was wondering - is there some wrapper clas

8条回答
  •  青春惊慌失措
    2020-12-16 14:38

    Visual C++ 2008 supports TR1 through the Feature Pack, and TR1 includes shared_ptr. I would use this -- it's a very powerful smart pointer class and can be generalized to do the type of resource management you are asking for.

    TR1 is effectively an extension to the Standard. I believe it's still officially "pre-standard", but effectively you can consider it locked down.

提交回复
热议问题