运行时提示错误basic_string::_S_construct|运行时提示错误basic_string::_S_construct null not valid

代码
char* xxx = func();
string yyy(xxx);
运行时提示错误:
terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid
【运行时提示错误basic_string::_S_construct|运行时提示错误basic_string::_S_construct null not valid】提示的错误已经很明确,是string构造不能传入空指针xxx,即在xxx为空时会报上面错误,保证func返回不为空即可。

    推荐阅读