Let's say whe have
class Foo{
public:
bool error;
......
bool isValid(){return error==false;}
};
and somewhere
Foo *aFoo=NULL;
I usually would do if (aFoo!=NULL && aFoo->isValid()).....
But what if in the isValid method I test the nullity:
bool isValid(){return this!=NULL && error==false)
That would simplify the external testing with simply calling if (aFoo->isValid())
I've tested it in some compilers and it works but I wonder if it is standard and could cause problems when porting to other environments.