M
muktipada
Hello,
As a C++ developer which one we should use for pointer assignment,
NULL or 0.
typedef DummyC DummyClass*; // in some header file.
DummyC obj = NULL;
if (obj == NULL) {
// It gives an impression that obj is a pointer
}
OR
DummyC obj = 0;
if (obj == 0) {
// it gives an impression that obj is an integer, which is not true.
}
I understand NULL is a macro and defined to 0. But for readibility
purpose should
we use NULL for poiner. and 0 for integer.
Also since system provide NULL to be defined to some value(today it is
0) and if
tomorrow the defined value changes, then still our code will be
portable
if we use NULL. So I think instead of using hard coaded value 0, we
should
use NULL for pointer. It increases both for readbility and
portability. Any suggestion?
Regards,
-mukti
As a C++ developer which one we should use for pointer assignment,
NULL or 0.
typedef DummyC DummyClass*; // in some header file.
DummyC obj = NULL;
if (obj == NULL) {
// It gives an impression that obj is a pointer
}
OR
DummyC obj = 0;
if (obj == 0) {
// it gives an impression that obj is an integer, which is not true.
}
I understand NULL is a macro and defined to 0. But for readibility
purpose should
we use NULL for poiner. and 0 for integer.
Also since system provide NULL to be defined to some value(today it is
0) and if
tomorrow the defined value changes, then still our code will be
portable
if we use NULL. So I think instead of using hard coaded value 0, we
should
use NULL for pointer. It increases both for readbility and
portability. Any suggestion?
Regards,
-mukti