c++ - std::string::clear 和 std::list::clear 是否从内存中删除数据

标签 c++ string list

在 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/

相关文章:

c++ - 声明数组后,所有元素都以某种方式成为最后一个元素

c++ - 在 C++ 中存储对数组的引用

mysql - 在 MySql 存储过程中有长字符串

c# - 使用 LINQ 在 IList 中查找项目

python - 如何通过将列表元素与Python中的字符串进行比较来找到列表元素的索引?

javascript - 对具有跨度的列表进行排序,jQuery

c++ - C++(非 C)中的轻量级 HTTP/HTTPS 服务器

c++ - 修改自己类的本地实例

c - 如何去掉字符串开头的 '\n'

c# - 从字符串中删除字符的最快方法