没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/85384960/bg1.jpg)
1
本讲知识要点
6.5
6.5
深拷贝与浅拷贝
深拷贝与浅拷贝
6.6
6.6
字符串
字符串
9.1
9.1
函数模板
函数模板
9.2
9.2
类模板
类模板
![](https://csdnimg.cn/release/download_crawler_static/85384960/bg2.jpg)
2
2
6.5 深拷贝与浅拷贝
6.5 深拷贝与浅拷贝
•
浅拷贝
–
实现对象间数据元素的一一对应复制。
•
深拷贝
–
当被复制的对象数据成员是指针类型时,不是复制该指
针成员本身,而是将指针所指对象进行复制。
![](https://csdnimg.cn/release/download_crawler_static/85384960/bg3.jpg)
3
例 6-21 对象的浅拷贝
#include <iostream>
#include <cassert>
using namespace std;
class Point {
// 类的声明同例 6-16
//……
};
class ArrayOfPoints {
// 类的声明同例 6-18
//……
};
![](https://csdnimg.cn/release/download_crawler_static/85384960/bg4.jpg)
4
例 6-21 ( 续 )
int main() {
int count;
cout << "Please enter the count of points: ";
cin >> count;
ArrayOfPoints pointsArray1(count); // 创建对象数组
pointsArray1.element(0).move(5,10);
pointsArray1.element(1).move(15,20);
ArrayOfPoints pointsArray2(pointsArray1); // 创建副
本
cout << "Copy of pointsArray1:" << endl;
cout << "Point_0 of array2: " <<
pointsArray2.element(0).getX() << ", "
<< pointsArray2.element(0).getY() << endl;
cout << "Point_1 of array2: " <<
pointsArray2.element(1).getX() << ", "
<< pointsArray2.element(1).getY() << endl;
![](https://csdnimg.cn/release/download_crawler_static/85384960/bg5.jpg)
5
例 6-21 ( 续 )
pointsArray1.element(0).move(25, 30);
pointsArray1.element(1).move(35, 40);
cout << "After the moving of pointsArray1:" <<
endl;
cout << "Point_0 of array2: " <<
pointsArray2.element(0).getX() << ", "
<< pointsArray2.element(0).getY() << endl;
cout << "Point_1 of array2: " <<
pointsArray2.element(1).getX() << ", "
<< pointsArray2.element(1).getY() << endl;
return 0;
}
剩余49页未读,继续阅读
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
matlab大师
- 粉丝: 2507
- 资源: 8万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 基于快速傅里叶变换算法的蜂鸣器音频分析技术
- 高分项目,PID-电机类-开源工业伺服电机PID控制,源码+原理图+操作手册
- 高分项目,PID-电机类-超级牛的STM32 BLDC直流电机控制器设计,附原理图和源码
- 高分项目,PID-电机类- 基于红外遥控的多功能智能电风扇控制器源码
- 高分项目,PID-电机类- 基于NRF24L01的PID电机转速控制器,源码+无线PID电机转速控制器+接收机
- 基于Matlab读取sif格式文件,并且画图
- Python基于Django图书管理系统(源码+数据库脚本+截图)高分期末大作业
- Screenshot_20240619_075859.jpg
- 210501230212
- JavaWeb停车收费管理系统的设计与实现
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0