在 string::clear 函数的描述中,它说:
clear: Erases the contents of the string, which becomes an empty string (with a length of 0 characters).
在 list::clear 函数的描述中,它说:
clear: Removes all elements from the list container (which are destroyed), and leaving the container with a size of 0.
清除是覆盖字符串和列表的内存还是只是释放它们?
最佳答案
这两个函数都不需要覆盖已删除的数据。
关于c++ - std::string::clear 和 std::list::clear 是否从内存中删除数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17579588/