I'm currently learning about Pointers...
The book says that wild pointers " pointers that are not initialized " are VERY dangerous!
why are they dangerous ?
I'm currently learning about Pointers...
The book says that wild pointers " pointers that are not initialized " are VERY dangerous!
why are they dangerous ?
I have a code which stops life!
Because they don't point to anything, meaning they could crash your program. Also read up on pointers, after you are done you should intialise them to NULL.
An uninitialised pointer could point to any location. So if you;
int* ptrI;
*ptrI = 10;
It may work once or twice (because the location of the pointer may point to a safe area of memory), but then crash without warning then next time.
If you;
int* ptrI = 0;
*ptrI = 10;
Then it will crash every time, but the reason for the crash given by your debugger or the os gives you good hint to look for a point in your code where you dereference a null pointer
Uninitialized pointerse point to a location in mem. If you don't assign them values, they use the values that are already in the little ram piece they've selected.
try this and see for yourself:
Very annoying.Code:int* x; cout << *x;
--Ashiq