【发布时间】:2013-08-24 00:03:51
【问题描述】:
我是 C++ 的新手。我在我的代码中遇到了 std::unique_ptr 和 std::shared_ptr 的用法
typedef std::unique_ptr<type1> type1Handler;
typedef std::shared_ptr<type2> type2Handler;
我有两个问题:
- 使用
unique_ptr和shared_ptr有什么好处 - 它们之间的主要区别是什么?
举个例子可能会很有帮助!
【问题讨论】:
-
你试过谷歌吗?