Constructor return value

Yesterday I attended an on-line interview. One of the questions asked was about constructors. I don’t remember the exact question, but part of it was testing my knowledge on constructor return values.

I just read up in Bruce Eckel just now, that constructors do NOT return anything. The more I think about the way I usually see them initialized, the more I feel that I was really an idiot yesterday. That question had me for about 5 minutes !! (Felt like 1 hour to me)

We can pass values into constructors, but I can’t think of any language where constructors return anything. Hmm…

Advertisements