0

Do constructors return a value?

28th Oct 2017, 4:47 PM
CoderAss
CoderAss - avatar
3 Réponses
+ 16
They always return an instance of the class ;) You can't change this behavior, so constructors don't need a return type.
28th Oct 2017, 5:36 PM
Tashi N
Tashi N - avatar
+ 7
No, they don't. Not even void. After all, you cannot get anything of value from creation of an object. And void would make it more like a function.
28th Oct 2017, 4:51 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
ya constructor don't have any return type
28th Oct 2017, 5:16 PM
Nanda Balakrishnan