关于拷贝构造函数和等号运算符重载的试验
来源:互联网 发布:网络胜利组剧情 编辑:程序博客网 时间:2024/06/16 18:33
#include <iostream>
#include <stdlib.h>
using namespace std;
class myclass
{
public:
myclass()
{
cout << "This is myclass()" <<endl;
};
myclass(const myclass &oldone);
void operator=(const myclass &);
private:
int _a;
int _b;
int _c;
};
int main()
{
myclass xx;
myclass yy(xx);
myclass zz = xx;
xx = yy;
system("pause");
return 0;
}
myclass::myclass(const myclass &oldone)
{
cout << "This is myclass(const myclass &oldone)" <<endl;
_a = oldone._a;
_b = oldone._b;
_c = oldone._c;
}
void myclass::operator=(const myclass &oldone)
{
cout << "This is =(const myclass &oldone)" <<endl;
_a = oldone._a;
_b = oldone._b;
_c = oldone._c;
}
结果如下图:
- 关于拷贝构造函数和等号运算符重载的试验
- 关于重载拷贝构造函数和赋值运算符
- 关于拷贝构造函数和重载成员运算符=
- 对象隐式转换,复制构造函数和重载等号运算符的区别
- 类的赋值运算符重载和拷贝构造函数
- 拷贝构造和赋值运算符函数的重载
- C++中关于拷贝构造函数和重载赋值运算符的一些体会
- 关于拷贝构造函数和赋值运算符重载的看法
- c++拷贝构造函数遇上等号重载
- 用String类的实验,说明拷贝构造函数、重载等号赋值函数、和普通构造函数的区别
- C++--拷贝构造函数与等号运算符
- 【C++】复制构造函数(拷贝构造函数)和=运算符重载使用的区别
- C++赋值运算符重载函数和拷贝构造函数
- 拷贝构造函数与赋值运算符的重载函数
- 拷贝构造函数和赋值运算符重载
- [C++]拷贝构造函数和赋值运算符重载
- 拷贝构造函数和赋值运算符重载
- 类设计中的重载运算符和拷贝构造函数
- 无聊
- Prototype 介绍
- 使用log4j的输出自己想要的文件
- 当前页居中分页效果的JS实现
- WebSphere性能诊断与调优
- 关于拷贝构造函数和等号运算符重载的试验
- 开始
- 学习了
- DOMDocument 与 FreeThreadedDOMDocument 的使用方法
- 一个让很多人伤脑经的Java技术问题
- javascript API
- LoadRunner 安装方法与系统环境初始化过程
- 学习struts-hibernate-spring
- VS 2010构建云服务