question about null check.

Feb 27, 2013 at 6:48am
I have a Class A.
and,

A *testA = new A();
A *testB = new A();

testB = testA;

if(testA)
{
delete testA;
testA = NULL;
}

after that, the address of testB is 0xfeeefeee, not NULL(0x00000000).
how to check if testB is NULL or not?

Feb 27, 2013 at 6:53am
You can't. You assigned B the address of A, changing A won't change B.
It's usually best not to have multiple pointers to one object.

EDIT: Although I guess you could make B a reference to A.
Last edited on Feb 27, 2013 at 6:54am
Feb 27, 2013 at 7:07am
I got it.
I was going to wrong way. Thanks.
Topic archived. No new replies allowed.