#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 morning,code monkeys!");
a.output();
A b("good afternoon,codes!");
b.output();
return 0;
}
11-06