gpt4 book ai didi

c++ - C++变量销毁

转载 作者:行者123 更新时间:2023-12-02 09:47:46 24 4
gpt4 key购买 nike

假设我有这个:

std::wstring str = std::to_wstring(100);
str = std::to_wstring(1000); // Is the previous str destroyed?
如果我将局部变量重新分配给另一个变量,旧变量会被销毁吗?

最佳答案

Is the previous str destroyed?


是。您共享的代码段中没有发生内存管理,而是全部自动存储。

关于c++ - C++变量销毁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63944427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com