Memory release while running a secvence of code.

I am trying to understand:
Is the memory relase proper in this sequence of code?
How is the memory released, and through which steps did it go?
What those steps means?
Is there any suggestions of how to understand the memory release concept that you can share with me please?

#include <iostream>

using namespace std;

class Test
{
int * _p;
public:
Test(int val):
_p(NULL)
{
_p = new int;
if(0 == val % 2)
{
throw val;
}
* _p = val;
}
~Test()
{
cout << "~Test()" << endl;
if(NULL != _p)
{
delete _p;
}
}
};

int main()
{
try
{
Test t(2);
}
catch(int)
{
}
}
Last edited on
Topic archived. No new replies allowed.