Topic: Constructor Chaining


Author: hattons@globalsymmetry.com ("Steven T. Hatton")
Date: Fri, 15 Dec 2006 21:51:17 GMT
Raw View
A long time ago I was told there was discussion of introducing to C++ the
ability of a constructor to call another constructor of the same class.
This is a feature found in Java which seems to make a lot of sense, and, as
far as I am aware, introduces no fundamental problems.  This is different
from the existing C++ facility for calling a base class constructor in the
member initialization list.  What happens is that one constructor calls
another constructor of the same class as if it were any other member
function.

Has that functionality been discussed by C++ language designers?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: "Vidar Hasfjord" <vattilah-groups@yahoo.co.uk>
Date: Sat, 16 Dec 2006 01:37:23 CST
Raw View
"Steven T. Hatton" wrote:
> A long time ago I was told there was discussion of introducing to C++ the
> ability of a constructor to call another constructor of the same class.
> [...]
> Has that functionality been discussed by C++ language designers?

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: "=?iso-8859-1?q?Pedro_Lamar=E3o?=" <pedro.lamarao@gmail.com>
Date: Mon, 18 Dec 2006 11:07:27 CST
Raw View
On 16 dez, 05:37, "Vidar Hasfjord" <vattilah-gro...@yahoo.co.uk> wrote:
> "Steven T. Hatton" wrote:
> > A long time ago I was told there was discussion of introducing to C++ the
> > ability of a constructor to call another constructor of the same class.
> > [...]
> > Has that functionality been discussed by C++ language designers?
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf

There is an implementation for GCC here:

http://mndfck.org/~pedro.lamarao/projects/c++0x/

It is provided as a patch to the current mainline version, and has just
a couple of test cases.

--
 Pedro Lamar   o


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]