Is it a good practice to use the static member methods to check if an object of a class is NULL or not. The object would be sent through the parameters offcourse.
Something like,
#include <iostream>
using namespace std;
class Box {
public:
static int checkNull(Box* b) {
if (b != NULL)
cout << "present\n";
else
cout << "absent\n";
}
};
int main() {
Box *b1, *b2;
Box b;
b1 = b2 = NULL;
b1 = &b;
Box::checkNull(b1);
Box::checkNull(b2);
return 0;
}
checkNullmethod inside theBoxclass, since it contains only a fictional action which is in no way related to aBox. Write a better question, get a better answer.