jl_post@hotmail .com wrote:
Yes, certainly.
Actually 'delete' is an operator, not a function. The parens are
superfluous.
There is really no need for that.
Why?
Yes, it is.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
I've wondered for quite some time if it's legal to make a reference
to a pointer, like this:
>
void f()
{
SomeClass *ptr = new SomeClass;
>
SomeClass & ref = *ptr; // is this legal?
to a pointer, like this:
>
void f()
{
SomeClass *ptr = new SomeClass;
>
SomeClass & ref = *ptr; // is this legal?
>
// Do stuff with ref here.
>
delete(ptr);
// Do stuff with ref here.
>
delete(ptr);
superfluous.
ptr = NULL;
return;
}
>
Ordinarily I'd say this is legal, but I haven't read any
documentation that explicitly says so.
>
(Now, I understand that it's bad form to allocate memory and free/
delete it in the very same scope,
}
>
Ordinarily I'd say this is legal, but I haven't read any
documentation that explicitly says so.
>
(Now, I understand that it's bad form to allocate memory and free/
delete it in the very same scope,
but I just want to know if it's okay
to declare a reference to a (de-referenced) pointer, assuming the
pointer points to a valid object and that the reference is not used
after the memory is freed/deleted.)
to declare a reference to a (de-referenced) pointer, assuming the
pointer points to a valid object and that the reference is not used
after the memory is freed/deleted.)
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Comment