#Handle Err In Constructr
10-Jul-94 15:29:57
Sb: #30375-#Handle Err In Constructr
Fm: Michael Meadows [MVP] 75570,3167
To: Kwong-hip Chan 70164,112
Kwong-hip,
>Please show me a way to handle errors inside a constructor.
Until VC++ comes out with real exception handling, you have two options.
1. Add a flag to the class' members, and have the ctor set the flag to indicate
success or failure. Then the calling function can check to see if the
construction was successful.
2. Only do safe operations in the ctor, and add an Init function to the class
which must be called by the calling function after the ctor is called. This
function can return a value indicating success or failure.
Michael Meadows