Perhaps I'm missing something here but if a constructor fails it will usually be because of some type of memory issue. The object creation is handled by the compiler and simply reduces down to a simple memory allocation for space in which to store the object (basically).
So, in essence, you will know if the object failed by testing the pointer. There is no need to put this checking in every one of your classes. It is up to the programmer who creates the object to ensure that the pointer is valid before they use it.
For instance in DirectX when you create an interface(get a pointer to an interface) you should always check to see if it is valid using the FAILED() macro.
You can do the same type of thing:
Code:
char *test=new char[4000];
if (test)
{
...allocation succeeded - pointer is valid
} else ...allocation failed - pointer is not valid
Code:
//Placed into a header file
class Example
{
int SomeValue1;
int SomeValue2;
public:
Example(void) {SomeValue1=0;SomeValue2=0;};
};
//Placed into a code module - separate from the header
Example *ThisExample=new Example();
if (ThisExample)
{
...object was created/allocated - pointer is valid
...SomeValue1 is now 0 as well as SomeValue2
}
else
{
...object was not created - pointer is not valid
...SomeValue1 is invalid as well as SomeValue2
}
So it is not up to the class creator/designer to check to see if the object is created or not - it is the responsibility of the programmer who instantiates the class. As far as I'm concerned it is a bad practice to put error checking like this in the class definition since it really has nothing to do with the definition of the class. It has to do with the instantiation of the class.
As well it is also not the responsibility of the class or class designer to make sure that an object has been destroyed, freed, or deallocated.
Remember that when you create a class it is not an object yet. It is not an object until you instantiate the class which is going to be done from outside the class by whoever needs to use the class. So to check whether a class is a valid object or not a valid object from inside the class definition, which is not an object yet, is really useless which is probably why destructors and constructors do not and cannot have a return type.
You might want to read up on C++ and how classes are instantiated to understand more. Perhaps you need to rethink what you are trying to do.
Hope this helps.