<分区>
我有 std::string 指针,我喜欢将它的值复制到普通的 std::string 我找不到快速的方法来做到这一点。 我有这个:
int main ()
{
std::string * pStr = new std::string("hello")
std::string strNew = pStr->??? // how to convert ?
return 0;
}
<分区>
我有 std::string 指针,我喜欢将它的值复制到普通的 std::string 我找不到快速的方法来做到这一点。 我有这个:
int main ()
{
std::string * pStr = new std::string("hello")
std::string strNew = pStr->??? // how to convert ?
return 0;
}
最佳答案
取消引用:
std::string strNew = *pStr;
关于c++ - 如何将 std::string 指针转换为 std::string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18932321/