This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Error on Member Initialization
- From: John Love-Jensen <eljay at adobe dot com>
- To: lrtaylor at micron dot com, gcc-help at gcc dot gnu dot org
- Date: Mon, 15 Sep 2003 12:37:15 -0500
- Subject: Re: Error on Member Initialization
Hi Lyle,
>Is there any _real_ difference between these two ways of initializing?
Yes. The real difference is that the initializer list occurs whether or not
it is explicitly specified. Putting the initialization code in the
constructor's body MAY incur a performance penalty. That's a MAY, not a FOR
SURE ... the only way to know for certain is by profiling the optimized
release executable.
In some situations, it is necessary to put more complex resource acquisition
code in the constructor's body.
But, generally speaking, initialization lists are preferable over
initialization via the constructor's body.
The sample code you presented is amenable to the preferred initialization
list solution.
HTH,
--Eljay