ya************@gmail.com wrote:
hello, may i know how i can determine whether a pointer is pointing to
an array or a single item during runtime?
There is no portable way.
this is because in certain situation, i need to determine whether to
use delete or delete[] to deallocate the item(s) ponting by the
pointer.
If it's you who allocated it, you know how to delete it. If it's not
you who allocated it, you shouldn't be responsible for deletion.
>
also, is there any way to determine whether the allocated memory
pointed by the pointer is allocated through new or c version calloc/
malloc?
No, not portably. In most cases the developers decide to only use
one method. I say, use 'new' and don't concern youself with anything
else.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask