代码:
#include <stdio.h>
#include <string>
int main(int argc, char* argv[])
{
std::string str(NULL);
return 0;
}
linux下运行结果:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
已放弃(吐核)
所以在给string对象赋值时,先校验源对象是否等于NULL很重要;
版权声明:本文为m0_37876242原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。