Link to home
Start Free TrialLog in
Avatar of BrianMc1958
BrianMc1958

asked on

NEWBIE: Please advise on returning status of constructor

Dear Experts,

Given that constructors can't return anything, what is the preferred method of findiing out about their success?

As an example, I have a class that encapsulates a specific text file.  I try to load the text file in the constructor.  If the text file is not found, the class is worthless.  Ideally, my constructor would return a boolean, indicating it couldn't find the file.

Given that I can't do that, what's the next best thing?  I know I could set a class boolean, and then query that, but that seems awkward...

Thanks,
BrianMc1958
ASKER CERTIFIED SOLUTION
Avatar of CPColin
CPColin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BrianMc1958
BrianMc1958

ASKER

To CPColin:  I should have thought of that!  Once you've explained it to me, it seems obvious.  Thanks very much.
Happy to help!