我想在我的程序中释放内存。
虽然我是新手,但我非常关心性能。
string i_want_to_delete_this = "I don't want this cleared, but
completely gone";
/* I figured out */ i_want_to_delete_this.clear() /* simply sets the
string value to "". I want to be able to do this with every
datatype! I want it completely gone, not even declared anymore. */
最佳答案
我不明白你为什么要这样做,并且在任何情况下你都不能删除或以其他方式删除命名变量,除非它们在概念上由编译器在它们超出范围时为你删除,并且当包含它们的函数退出时实际上被删除。例如:
{
{
string i_want_to_delete_this = "I don't want this cleared, but
completely gone";
} // it's gone
}
关于c++ - 如何删除C++中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41598011/