On Apr 15, 4:32 am, Ian Collins <ian-n...@hotmail.comwrote:
Warren Tang wrote:
Does C++ allow a constructor to call another constructor of
the same class?
No, if you have common initialisation code, it can go in a
member function.
More precisely, not yet. A proposal for this has been accepted
for the next version of C++.
Note that in this case, the call 1) must be in the
initialization list (and not in the body of the constructor),
and 2) once the first constructor has finished, the object is
considered "completely constructed", i.e.:
C::C( ... )
: member1( ... )
, member2( ... )
{
throw something ; // will not call destructor...
}
c::C( ... )
: C( transformed .. )
{
throw something ; // will call destructor...
}
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34