您的位置:首页 > 其它

深复制

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;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: