question about null check.

I have a Class A.

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

testB = 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?

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
I got it.
I was going to wrong way. Thanks.
Topic archived. No new replies allowed.