I am learning C++ and I came to know that pointers if left uninitialized could point to random locations in memory and create problems that memory might be used by some other program.
Now if that is the case we should never have this line in any part of our code:
int* ptr;
Instead we should have something like
int* ptr = NULL; //Is this going to avoid the problem
Please suggest because I have seen the first line(int* ptr;
) in many books so I am getting this doubt. If possible give some examples also.