Jay*_*esh 0 c++ free new-operator dynamic-memory-allocation
我只是很想知道,如果在释放新运算符分配的内存之前会发生什么,会发生异常?是否发生了内存泄漏问题?
#include <iostream>
#include<new>
using namespace std;
void func()
{
try
{
int *p = new int[10];
/*
Number of lines code here
.
.
.
.
.
Suppose here I got exception then What heppens????
.
.
.
.
*/
delete []p;
}
catch(const std::exception& e)
{
cout<<"Exception occured"<<endl;
}
}
int main() {
func();
return 0;
}
Run Code Online (Sandbox Code Playgroud)