标签:
下面程序会崩溃:
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;
c++,当const char*为0时,不能将其直接赋给string
标签:
原文地址:http://www.cnblogs.com/wantnon/p/4524829.html