第九周项目1-深复制体验(1)
2016-05-11 14:15
274 查看
*All rightreserved.
*文件名称:test.cpp
*作 者:张明宇
*完成日期:2016年5月2日
*/
问题及代码:
阅读下面的程序,补足未完成的注释
*文件名称:test.cpp
*作 者:张明宇
*完成日期:2016年5月2日
*/
问题及代码:
阅读下面的程序,补足未完成的注释
#include<iostream> #include<cstring> using namespace std; class A { private: char *a; public: A(char *aa) { a = new char[strlen(aa)+1]; //(a)这样处理的意义在于:______________________________ strcpy(a, aa); //(b)数据成员a与形式参数aa的关系:___________________________________ } ~A() { delete []a; //(c)这样处理的意义在于: ___________________________________________ } void output() { cout<<a<<endl; } }; int main(){ A a("good morning, code monkeys!"); a.output(); A b("good afternoon, codes!"); b.output(); return 0; }
#include<iostream> #include<cstring> using namespace std; class A { private: char *a; public: A(char *aa) { a = new char[strlen(aa)+1]; //(a)这样处理的意义在于:_______对函数赋值_______________________ strcpy(a, aa); //(b)数据成员a与形式参数aa的关系:______复制函数_____________________________ } ~A() { delete []a; //(c)这样处理的意义在于: ______释放数组_____________________________________ } void output() { cout<<a<<endl; } }; int main(){ A a("good morning, code monkeys!"); a.output(); A b("good afternoon, codes!"); b.output(); return 0; }
相关文章推荐
- 解决ajax请求跨域的两个方法
- ios导航栏rightBarButtonItems多个按钮自定义设置
- 开发者选用国内哪家移动广告平台赚钱
- Eclipse debug neutron-server
- MLeaksFinder:精准 iOS 内存泄露检测工具
- ehcache 分布式集群同步数据实例
- Oracle Developer Suite 10g在Windows7下的安装方法
- 开发文档生成工具----Doxygen自动文档生成工具在Eclipse中的集成及使用举例
- IOS开发教程01
- 【Android】Eclipse安装ADT - 失败的处理办法 - 手动安装ADT
- 不要在init和dealloc函数中使用accessor
- 今天在使用JavaScript的eval时,出现了IE8的兼容性问题
- 【S2HS学习笔记】第三章节:Hiberbate的基本用法03
- 下载文件思路
- linux API之system()
- 《Motion Design for iOS》(十五)
- JDK的安装及环境变量的配置
- 清空NSUserDefaults
- Java生成圆角图标
- 汇编学习第四课之main函数反汇编