指针类 目的:使代码干净,降低了一点效率

来源:互联网 发布:手机淘宝怎么抢购秒杀 编辑:程序博客网 时间:2024/04/29 19:39
#pragma once template<class T>struct pointer{T* ref; pointer():ref(0){} pointer(T* _p):ref(_p){} T* operator -> (){return ref;} pointer<T>& operator = (const pointer<T> _right){ref = _right.ref;return *this;} pointer<T>& operator = (T* _right){ref = _right;return *this;} bool operator == (T* _right){return ref == _right;} operator T* (){return ref;} bool empty(){return ref == 0;} bool valid(){return ref != 0;}};
原创粉丝点击