下面程序会崩溃:
const char* t_objName = (obj!=NULL)?obj->getName(): 0;
string objName=t_objName;
cout<<objName<<endl;
应改为:
const char* t_objName = (obj!=NULL)?obj->getName(): 0;
string objName=(t_objName==0)?"":t_objName;
cout<<objName<<endl;
下面程序会崩溃:
const char* t_objName = (obj!=NULL)?obj->getName(): 0;
string objName=t_objName;
cout<<objName<<endl;
应改为:
const char* t_objName = (obj!=NULL)?obj->getName(): 0;
string objName=(t_objName==0)?"":t_objName;
cout<<objName<<endl;