C++拷贝构造函数
来源:互联网 发布:对数据库安全性的认识 编辑:程序博客网 时间:2024/06/07 05:35
#include <iostream>using namespace std;class Test1{public: Test1() { //赋值 //p=NULL; // or p=new int; } //重要 Test1& operator=(const Test1& test1) { if(&test1!=this) { cout << "赋值操作符" << endl; } return *this; } ~Test1() { cout<<"Test1 destructor"<<endl; if(p!=NULL) delete p; }private: int *p;};class Test2{public: Test2(const Test1& test1) { a=test1; } ~Test2() { cout<<"Test2 destructor"<<endl; }private: //Test a; Test1 a;};int main(){ Test1 test1; Test2 *c=new Test2(test1); delete c; //system("pause"); return 0;}
0 0
- 【C++】拷贝构造函数
- C++:拷贝构造函数
- c++"拷贝构造函数
- C++: 拷贝构造函数
- 【C++】拷贝构造函数
- c++::拷贝构造函数
- 【C++】:拷贝构造函数
- 【C++】拷贝构造函数
- C++:拷贝构造函数
- C++_拷贝构造函数
- C++_拷贝构造函数
- 拷贝构造函数(C++)
- 拷贝构造函数(C++)
- C/C++ 拷贝构造函数
- c++(拷贝构造函数)
- 5.c++-拷贝构造函数(深拷贝,浅拷贝)
- c++_拷贝构造函数/浅拷贝/深拷贝
- 【C++】拷贝构造函数和赋值函数
- 通过Leetcode::Bitwise AND of Numbers Range 深化对比特位计算的理解
- svn diff 使用 vimdiff代替,提高阅读性
- 浙江大学PAT_乙级_1005. 继续(3n+1)猜想 (25)
- UVa 257 - Palinwords
- 再学JavaScript-第五课-深入理解面向对象
- C++拷贝构造函数
- 深入Qt 学习 -- 反射机制
- rocksdb使用
- NSString和NSMutableString
- uva 1592
- 数独游戏
- Java语法小记
- Android View绘制及实践
- 第K短路