深复制
2016-06-13 15:28
323 查看
/* *烟台大学计算机学院 *文件名称:main.cpp *作 者:王者健 *完成日期:2016年6月13日 *版 本 号:codeblocks 16.01 */ #include <iostream> #include<cstring> using namespace std; class A { private: char *a; public: A(char *aa) { a=new char[strlen(aa)+1]; strcpy(a,aa); } ~A() { delete[]a; } void output() { cout<<a<<endl; } }; int main() { A a("good moring,code monkeys!"); a.output(); A b("good afternoon,codes!"); b.output(); return 0; }
相关文章推荐
- Python
- 整型变量是一个变量
- TextField文本域对象的用法
- 网页特殊符号
- 前台post通过web api向数据库中添加数据
- 聊聊HTTPS和SSL/TLS协议
- 网页特殊符号
- 第5章
- hdu 2078(DFS)
- android技巧总结
- struts2 result type类型
- 各种 Java Thread State 第一分析法则
- Netty入门三:Netty概要讲解,全面了解Netty,做到胸有成竹
- leetcode 189. Rotate Array
- 关于Python中的yield
- 【HDU】 1787 GCD Again
- leetcode2 add two number
- BootStrap智能表单实战系列(九)表单图片上传的支持
- 通过adb录制视频并通过FFMPEG将MP4转换成GIF格式(一)
- 多线程 - 原子量AtomicLong