How should a contructor handle a failure?
- If construction fails at the runtime, it throws an exception.
- Constructor does not have return type, not even void. So, it is difficult to use return codes.
- Throws an exception is the best method to handle a failure constructor.
- If sometimes you cannot throw an exception just because of some reason, then there is another alternative to mark the object as a zombie.
Post a Comment