$someClass sc=new SomeClass();
What I want to know is what will be in the variable sc if the constructor fails for some reason (like maybe not enough memory). I can’ t find a straight answer?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A constructor can fail for mainly two reasons:
Out of memory; not unique to objects, this causes a fatal error and your script won’t continue.
An exception is thrown; your script will stop unless the exception is caught using a ‘try-catch’ clause.