条款16:在operator =中对所有数据成员赋值
来源:互联网 发布:linux查看线程cpu 编辑:程序博客网 时间:2024/05/22 03:18
class Base
{
public:
Base(int initialvalue = 0):x(initialvalue){}
private:
int x;
};
class Derived:public Base
{
public:
Derived(int initialvalue):Base(initialvalue),y(initialvalue){}
Derived& operator=(const Derived& rhs)
{
if(this == &rhs)
return *this;
Base::operator=(rhs);
y = rhs.y;
return *this;
}
private:
int y;
};
{
public:
Base(int initialvalue = 0):x(initialvalue){}
private:
int x;
};
class Derived:public Base
{
public:
Derived(int initialvalue):Base(initialvalue),y(initialvalue){}
Derived& operator=(const Derived& rhs)
{
if(this == &rhs)
return *this;
Base::operator=(rhs);
y = rhs.y;
return *this;
}
private:
int y;
};
- 条款16: 在operator=中对所有数据成员赋值
- Effective C++ 条款16: 在operator=中对所有数据成员赋值
- effective C++笔记之条款16: 在operator=中对所有数据成员赋值
- 条款16:在operator =中对所有数据成员赋值
- 条款 16: 在 operator=中对所有数据成员赋值
- 在operator=中对所有数据成员赋值
- 在operator=中对所有数据成员赋值
- Effective C++学习笔记:在operator=中对所有数据成员赋值
- 在operator=或拷贝构造中对所有数据成员赋值
- 条款11: 在operator= 中处理"自我赋值"
- 条款11:在operator= 中处理“自我赋值”
- 条款11: 在operator= 中处理"自我赋值"
- 条款11:在operator = 中处理"自我赋值"
- 条款11:在operator=中处理“自我赋值”
- 条款11:在operator=中处理”自我赋值“
- 总结条款:11在operator=中处理“自我赋值”
- 条款11 在operator=中处理“自我赋值”
- 条款11:在operator=中处理“自我赋值”
- C++语法基础--模板实参推断,模板类型形参的实参的受限转换,模板实参推断与函数指针
- 如何制作一个类似Tiny Wings的游戏(2) Cocos2d-x 2.1.4
- abstract class与interface的区别
- 条款15:让operator=返回*this的引用
- 计算机网络8
- 条款16:在operator =中对所有数据成员赋值
- Spring MVC入门 —— 跟开涛学SpringMVC
- 弱类型、强类型、动态类型、静态类型语言的区别是什么?
- expect example
- 在EXTJS中使用Ext.Ajax.request实现传递主从表数据
- 条款17:在operator=中检查给自己赋值的情况
- Ubuntu Server 12.04 LTS 安装 AR8161 驱动
- 第三章 构造函数,析构函数,赋值操作符
- java 中解决中文乱码问题的方法(三法)