J
JKop
ES Kim posted:
The value for a null pointer is implementation defined.
Just because when you write:
int* k = 0;
it sets it to a null pointer, doesn't mean that the null pointer value is in
actual fact 0. Consider the following to be the definition of a pointer:
class *
{
public:
*& operator=(int value)
{
if ( !value )
{
//Set to null pointer value
}
else
...
}
};
-JKop
JKop said:If you use reinterpret_cast to convert a pointer value to an unsigned
integral value (assuming the integral type is large enough to hold the
value) and then reconvert it back, then you're left with a valid
pointer.
So while the following may be invalid:
int jack[6];
int* p = jack;
--p; //There may be overflow, for instance if p == 0
That is, if p is null pointer?
Surely you're joking, Mr. JKop. ;-)
The value for a null pointer is implementation defined.
Just because when you write:
int* k = 0;
it sets it to a null pointer, doesn't mean that the null pointer value is in
actual fact 0. Consider the following to be the definition of a pointer:
class *
{
public:
*& operator=(int value)
{
if ( !value )
{
//Set to null pointer value
}
else
...
}
};
-JKop