19:29:36 19:29:36
class Person{
public:
Person(char * pN){
cout<<“Constructing”<<pN<<endl;
pName = new char[strlen(pN)+1];
if(pName) strcpy(pName,pN);
}
~Person(){
cout<<“Destructing”<<pName<<endl;
pName[0]=‘\0’;
delete pName;
}
protected:
char * pName;
};
void main(){
Person p1(“Ready”);
Person p2(p1);
}
pName
p1
pName
p2
堆内存
评论0
最新资源