You need to throw an exception. This is the best way to handle the creation of a failed object.
Constructor failures should be interesting to read from Herb Sutter GOTW.
Another way to do this is that if the constructor encounters an error, set the status bit and allow the user to call IsOK() to see if the construct is actually built.
But it is considered Obsolete .
The grass says:
I found that "if the constructor encounters an error, sets the status bit and allows the user to call IsOK () to see if the construct is really built," the method is deprecated, dangerous, tedious, and in no way better than throwing an exception.
source share