class A
{
public:
A()
{
try
{
p = new int;
//Other lines that may throw exception.
}
catch(...)
{
delete p;
}
private:
int *p;
};
In the above code, catch the exception in A's constructor to delete p.
Is it OK? Is there a better way to delete p?
Thanks.
Jack
{
public:
A()
{
try
{
p = new int;
//Other lines that may throw exception.
}
catch(...)
{
delete p;
}
private:
int *p;
};
In the above code, catch the exception in A's constructor to delete p.
Is it OK? Is there a better way to delete p?
Thanks.
Jack
Comment