Connecting Tech Pros Worldwide Forums | Help | Site Map

Can one constructor of a class call another constructor of the same c

Newbie
 
Join Date: Jun 2007
Posts: 13
#1: Jun 22 '07
Can one constructor of a class call another constructor of the same class to initialize the this object?

dumparun's Avatar
Newbie
 
Join Date: Feb 2007
Posts: 26
#2: Jun 22 '07

re: Can one constructor of a class call another constructor of the same c


Quote:

Originally Posted by mahendra23

Can one constructor of a class call another constructor of the same class to initialize the this object?

No, its not possible.....
Even if you try, then a temporary object is actually created and initialized and then discarded.

you can achieve the same effect by clubbing 1 or 2 constructors into a single constructor by giving default parameters.
Reply