【项目-深复制体验】
`#include<iostream>
#include<cstring>
using namespace std;
class A
{
private:
char *a;
public:
A(char *aa)
{
a = new char[strlen(aa)+1]; //(a)这样处理的意义在于:如果没有此操作a是一个野指针_____________________________
strcpy(a, aa); //(b)数据成员a与形式参数aa的关系:_________________________________
}
~A()
{
delete []a; //(c)这样处理的意义在于:释放a的地址 ___________________________________________
}
void output()
{
cout<<a<<endl;
}
A(const A &B)
{
a = new char[strlen(B.a)+1];
strcpy(a,B.a);
}
};
int main(){
A a("good morning, code monkeys!");
a.output();
A b(a);
b.output();
return 0;
}
`