c++ 给std::string 赋值 NULL 运行报错 , 编译正常

错误截图:

C++ std::string 不可初始化为NULL

 

 

字符串不可以初始化为NULL,虽然能通过编译,但是会出现运行错误 ,可以赋值为 "" (空字符串);

示例 :

std::string res1 = NULL    ; //  错误的
std::string res2 = ""      ; //  好使的

 

相关文章:

  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-09-02
猜你喜欢
  • 2022-12-23
  • 2021-10-17
  • 2023-03-18
  • 2021-09-16
  • 2021-06-07
  • 2022-12-23
相关资源
相似解决方案