Re: Error on Member Initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux