C++ 属性 及 nullptr
来源:互联网 发布:魔兽世界数据库2.43 编辑:程序博客网 时间:2024/05/29 15:13
template<class T>
class CNullPtr
{
T* m_ptr;
T m_value;
void SetValue(T value)
{
this->m_value = value;
m_ptr = &m_value;
}
void SetValue(const CNullPtr& source)
{
if(source.m_ptr == nullptr)
{
this->m_ptr = nullptr;
}
else
{
SetValue(source.m_value);
}
}
public:
CNullPtr():m_ptr(nullptr)
{
}
CNullPtr(CNullPtr& obj)
{
SetValue(obj);
}
void putprop(T j) {
SetValue(j);
}
T getprop() {
if(this->m_ptr==nullptr)
{
throw "使用空值。";
}
return m_value;
}
__declspec(property(get = getprop, put = putprop)) T Value;//定义属性
bool IsEmpty() {
if(this->m_ptr==nullptr)
{
return true;
}
return false;
}
CNullPtr& operator=(const T& rhs)
{
SetValue(rhs);
return *this;
}
CNullPtr& operator=(const CNullPtr<T>& rhs)
{
if (this == &rhs) return *this; // identity test: if a self-assignment,
SetValue(rhs);
return *this;
}
CNullPtr& operator=(std::nullptr_t rhs)
{
m_ptr = rhs;
return *this;
}
};
- C++ 属性 及 nullptr
- NULL、0、nullptr (C++)
- Modern C++(五)nullptr关键字
- nullptr
- nullptr
- nullptr
- nullptr
- nullptr
- C ++中的NULL与nullptr的区别
- C/C++之NULL、0、nullptr详解
- C/C++中的NULL与nullptr
- C中的链接属性及作用域
- C#—Form属性及方法
- createWithSpriteFrameName nullptr
- C++ nullptr
- nullptr介绍
- C++ nullptr
- nullptr 简介
- Maven3:用eclipse插件创建一个web project
- javascript 中的tagName 与 nodeName有什么不同
- 谈谈varnish,squid,apache,nginx缓存的对比
- linux内核中断、异常、系统调用的分析以及实践
- Linux内核模块的“加载”和“卸载”函数
- C++ 属性 及 nullptr
- myeclipse 7.5 安装 axis2 插件终极解决办法(转)
- SQL SERVER 远程访问失败
- Gallery自动循环滚动以及手动滚动的平滑切换
- 中断请求(IRQ)中断控制器(PIC) .
- 深入掌握JMS
- jsp、java程序和数据库之间中文乱码问题
- 实现一个ntohll
- spoj Circleland题解