Colin, On Thursday 21 April 2005 06:22, Colin Carter wrote:
On Thursday 21 April 2005 22:31, Randall R Schulz wrote:
Michael,
On Thursday 21 April 2005 02:48, Michael Stevens wrote:
...
In C++ it would seem that the 'const void * NULL = 0' definition would be a good thing as opposed to the literal '0' which Bjarne is recommending.
I used these routinely in my C++ work:
const void *NIL = 0; const char NUL = 0;
I should have written this, for the sake of pedanticness: const void *NIL = (void *) 0; const char NUL = (char) 0;
...
I like this idea - it makes it clear about what you mean, whereas (to me anyway) there is always confusion with NULL which is not even NUL.
How do you write that a pointer ptr is pointing nowhere?
A pointer of any sort that compares equal to 0 or which was initialized or assigned 0 is guaranteed not to be a valid pointer. The consequences of dereferencing such a pointer is undefined. On some systems it will generate a fault of some sort. On others you silently read or corrupt low memory (virtual or physical, as the case may be).
That is, the value of the pointer is zero. I mean so that it is clear that it is not pointing to a zero value. Pardon my ignorance, but my preference is for FORTRAN and we are positively discouraged from using pointers because all of our variables are in fact addresses (pointers) and not 'values' as in C.
As far as FORTRAN goes, de gustibus...
Regards, Colin
Randall Schulz