Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 为什么 shared_ptr 有一个显式的构造函数
这让我感到困惑,为什么std::shared_ptr<int> p1(new int(10));会在一段时间内正常,而在std::shared_ptr<int> p2 = new int(10);失败时?我认为两者应该以相同的方式构建。
std::shared_ptr<int> p1(new int(10));
std::shared_ptr<int> p2 = new int(10);