D
doublemaster007
Hi All
somePtr *obj =NULL; ----------------------------(1)
obj = new somePtr; -----------------------------(2)
if(obj!=NULL) ------------------------------(3)
{
//do somthing
}
Is this code correct?
first, "new" doesnt return NULL. I have read this some where. Or is
that (1) ensures obj NULL after (2)
AFAIK, new throws exeption. So will the (3) be exexuted?
Reason i am asking this is, Its become a practise that checking for
NULL instead of trying for exeption. Is the above code really correct?
One more question. If new fails, Do we need to call the destructor of
obj explicitly?? AFAIK objected isnt contructed so we donot need to
call destructor..am i right???
somePtr *obj =NULL; ----------------------------(1)
obj = new somePtr; -----------------------------(2)
if(obj!=NULL) ------------------------------(3)
{
//do somthing
}
Is this code correct?
first, "new" doesnt return NULL. I have read this some where. Or is
that (1) ensures obj NULL after (2)
AFAIK, new throws exeption. So will the (3) be exexuted?
Reason i am asking this is, Its become a practise that checking for
NULL instead of trying for exeption. Is the above code really correct?
One more question. If new fails, Do we need to call the destructor of
obj explicitly?? AFAIK objected isnt contructed so we donot need to
call destructor..am i right???