Quote Originally Posted by jacek View Post
It's also called a heap. This is the memory that your application can allocate and deallocate dynamically (using new/delete operators or their equivalents).


There should be "=" instead of ":", anyway in this snippet you:
  1. create a pointer,
  2. create a new Cat object,
  3. initialize the pointer to make it point to that object
  4. and finally you destroy that Cat object leaving a dangling pointer (i.e. a non-null pointer that doesn't point to any object).



Here you simply create a pointer without initializing it (and without disturbing any cats ). This is also a dangling pointer, because it points to some random address (although some compilers might set it to 0, but you shouldn't rely on that).

As another question! what is a Null-pointer and what is a non-null pointer? how can a pointer exist but doesn't point to anything?
Does these dangling pointers use memory? Is it possible to destroy them? Can these dangling pointers make some problem in the program?

thanks( lot's of questions and lot's of ignorance )