Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SmartPointer() : ptr(nullptr), counter(nullptr) {}
- SmartPointer(T* ptr) : ptr(ptr), counter(new ReferenceCounter(1)) {}
- SmartPointer(const SmartPointer<T>& other) : ptr(other.ptr), counter(other.counter)
- {
- if (counter)
- counter->AddRef();
- }
- ~SmartPointer()
- {
- if (counter)
- {
- counter->DelRef();
- if (counter->Count() == 0)
- {
- delete counter;
- delete ptr;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement