This reply is about the code in the OP, whereas a lot of the replies seem to be about some other code which is similar to the code in the OP, but where _fooObject is a pointer to a fooObject rather than a fooObject itself.
The source given is bizarre in the extreme.
If it is C++, then new cannot return 0, and should throw an exception.
If it is something not entirely unlike C++ where new returns 0 on failure (such things have been known to exist), then Construction is equivalent to:
bool someFubar::Construction(){ // no need for void in C++, it's not C
delete _fooObj; // nothing stops this getting called twice!
_fooObj = new fooObject(); // no need for this->, it's not Python
return _fooObj; // non-zero is true
}
someFubar::~someFubar(){
delete fooObj; // it's OK to delete NULL in C++.
}
Now we have a problem - if Construction is called twice, do we construct it again and return true as above, don't construct it again and return true as it's constructed, or don't construct it again and return false as it's an error to construct something twice?
Sometimes - for example for classes which manage external resources - you may want to implement them as a state machine which you create, then allocate the resource. This is reasonable where a resource can become invalid, so you would have to check the operations you perform on it anyway. Providing a conversion from the type to bool is the pattern using in the standard library for such resources. Normally you should construct an object in one go and expect it to be valid.
thisto access members, compare pointers withnull, test fornullbefore deleting, and use(void)to indicate no parameters came from the same lunatic.thisto access member functions. I do it all the time as I find it more readable (and sometimes of course the use ofthisis necessary). I agree with the rest of your rant (what isnullanyway?).thiswhere necessary, or where it enhances readability, or just using it everywhere for consistency, is fine. Prefixing members with warts so you never need to usethisis also fine, although not to my taste. Doing both is lunacy.