【问题标题】:will the Dynamically allocated memory be Automatically released,when the program ends [duplicate]程序结束时会自动释放动态分配的内存[重复]
【发布时间】:2017-07-06 06:38:55
【问题描述】:

示例如下:

int *p=new int;
system("Pause");
return 0;

如果我们不执行delete p操作,内存会在程序运行结束时自动释放。

【问题讨论】:

  • 仅供参考:请勿使用 system("pause");

标签: c++


【解决方案1】:

这取决于您使用的操作系统。 Linux 和 Windows 都会在进程终止时清理进程使用的所有资源。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-17
    • 2021-07-05
    • 2013-11-22
    • 1970-01-01
    • 2012-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多