Deleting char* after assigning it to a string variable

后端 未结 3 682
夕颜
夕颜 2021-01-23 04:14

I have executed the below code and it works perfectly. Since it is about pointers, I just want to be sure. Though I\'m sure that assigning char* to string makes a copy and even

3条回答
  •  感动是毒
    2021-01-23 04:36

    No, because std::string copies the contents of your char*, so you're free to delete it when you no longer need it.

提交回复
热议问题