Saturday, December 03, 2005

"Pointers" to ponder

I think the word "pointer" is big in the heads of all softies...yep.But I guess there is an easy way to understand them...trick is to think them as mere numbers.
So if that unique number is getting changed unnecessarily...we get a crash....similarly if that number is garbage we get a crash.

ex.CPointerExample *cpe;
cpe->method();//crash cpe is not yet a number i.e no value assigned
most cross referencing crashes can be avoided if we think of a pointer as numbers being passed around so if that number is being changed then there is a crash....

example:

Module 1:
CPointerExample *cpe;
cpe=new CPointerExample();
cpe->SomeUniqueMethod();

Module....n
has to use cpe of Module1

but here does CPointerExample *cpe=new CPointerExample();
cpe->SomeUniqueMethod();

we have a crash because cpe has changed....

0 Comments:

Post a Comment

<< Home