How to handle failure in constructor in C++?

If an object construction fails, throw an exception.

The alternative is awful. You would have to create a flag if the construction succeeded, and check it in every method.

Leave a Comment