Hi,
I do have doubt regading use of delete p . In most of the scenarios we call delete inside the destructor if we would have called something int *p = new int (10); but as per below code snippet (original code of delete p)
it already invoke the destructor then call the operator delete then why we should call delete p inside the
destructor.
// Original code: delete a;
if (a != NULL) {
a->~A();
operator delete(a);
}
code snippet where we call the delete a inside destructor
class B
{
int *a;
public:
B()
{
a=new int(90);
}
~B()
{
cout<<"B's destructor";
delete a;
}
void dial()
{
cout<<"dial the tone";
}
};
~Mohan