第六周项目一深复制体验(3)
2015-04-15 08:47
246 查看
*Copyright (c)2015,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:test.cpp *作 者:李文贺 *完成日期:2015年4月15日 *版 本 号:v1.0 *问题描述: *输入描述: *程序输出:结果 #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; } A(const A&b); }; A::A(const A &b) { a=new char[strlen(b.a)+1]; strcpy(a,b.a); } int main() { A a("good moring,code monkeys!"); a.output(); A b(a); b.output(); return 0; }
相关文章推荐
- 第六周 项目一-深复制体验
- 第六周项目一—深复制体验(2)
- 第六周项目一 深复制体验(2)
- 第六周项目一深复制体验(1)
- 第六周 项目一-深复制体验(2)
- 第六周 项目一 深复制体验3
- 第六周项目一深复制体验(2)
- 第六周 项目一-深复制体验(1)
- 第六周项目1-深复制体验(3-复制构造函数)
- 第六周 项目1 深复制体验
- 第六周项目一 深复制体验1
- 第六周项目1-2:深复制体验
- 第六周项目一 深复制体验(3)
- 第六周——项目一深复制体验(一)
- 第六周 项目一-深复制体验(3)
- 第六周 项目一--深复制体验(1)
- 第六周项目一 (1)(2) 深复制体验
- 第六周项目一:-深复制体验
- 第六周 项目一--深复制体验(2)
- 第六周【项目1-深复制体验】1