if you delete any pointer twice you will get error . setting it to null is important after deleting so next time you can check before deleting the same pointer if null then dont delete.
@zfjquery Except you don't set y to null, just x. And the condition tests whether y is null and only then tries to delete it, which doesn't make any sense.
So, your code as written actually works, but doesn't make any sense and will be “a big problem” when used in any program that has more than 10 lines of code.
can anybody think of a logical reason why i cant do "int* a,b;" and have them both be pointers?
jony1710 1 month ago
@jony1710 try "int *a, *b;" i think with "int* a,b;" you are only assigning a as a pointer and not b...
jamesllewellyn19 4 weeks ago
@jamesllewellyn19 ahh thanks man, that makes complete sense. happy 2012. :)
jony1710 3 weeks ago
at the end dnt do
delete x;
delete y; // this will be a big problem
so always do
delete x;
x = NULL;
if(!y) delete y;
zfjquery 11 months ago
@zfjquery That doesn't work either.
gsvick 11 months ago
@gsvick
if you delete any pointer twice you will get error . setting it to null is important after deleting so next time you can check before deleting the same pointer if null then dont delete.
zfjquery 11 months ago
@zfjquery Except you don't set y to null, just x. And the condition tests whether y is null and only then tries to delete it, which doesn't make any sense.
So, your code as written actually works, but doesn't make any sense and will be “a big problem” when used in any program that has more than 10 lines of code.
gsvick 11 months ago
This is great, thanks' a bunch man ;)
Ethaninja 1 year ago
yo des jambas b brash!
destructionman1 1 year ago
uhh, yeah sharing whatever...
stphnkng 1 year ago
haha, awesome!
shianaheavens 2 years ago
embarrassingly, this really helped... thanks :D
itsazy 2 years ago