You can use a special designated object as the null object in case of references as follows:
class SomeClass
{
public:
int operator==(SomeClass &object)
{
if(this == &object)
{
return true;
}
return false;
}
static SomeClass NullObject;
};
SomeClass SomeClass::NullObject;
void print(SomeClass &val)
{
if(val == SomeClass::NullObject)
{
printf("\nNULL");
}
else
{
printf("\nNOT NULL");
}
}