智能指针:shared_ptr简单实现
#include <iostream>
using namespace std;
template <typename T>
class Shared_ptr {
public:
Shared_ptr(T* p) : count(new int(1)), _ptr(p) {}
Shared_ptr(Shared_ptr<T>& other) : count(&(++*other.count)), _ptr(other._ptr) {}
T* o.
原创
2020-08-15 19:12:27 ·
236 阅读 ·
0 评论