Smart Pointer

来源:互联网 发布:估算网络机房电源容量 编辑:程序博客网 时间:2024/05/17 22:36

 

template <class T>
class SmartPtr
{
public:
  explicit SmartPtr(T* pointee) : pointee_(pointee);
  SmartPtr& operator=(const SmartPtr& other);
  ~SmartPtr();
  T& operator*() const
  {
   ...
   return *pointee_;
  }
  T* operator->() const
  {
   ...
   return pointee_;
  }
private:
  T* pointee_;
  ...
};

0 0
原创粉丝点击