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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Happy to help!
ASKER