Мне просто интересно узнать, что произойдет, если перед освобождением памяти, выделенной новым оператором, произошло исключение?Возникла ли проблема с утечкой памяти?
#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;
}