This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ extension
Supposed you have two constructor which initialize differently one
member of a class. If you provide a default initialization you call a
constructor, then you call a second constructor or a copy
constructor/assignment operator in your constructor. The override of
the default value cost the call of two constructors instead of one.
On 4/20/06, Perry Smith <pedz@easesoftware.com> wrote:
> I don't understand what you are saying.
>
> If you have several constructors, you have to initialize each member
> in each constructor or have one common constructor.
>
> If the new syntax was allowed, you could still do that. You could
> specify how to initialize it when the member is declared or you could
> specify it with each constructor. I'm not suggesting replacing the
> current syntax -- just adding to it.
>
> Perry
>
> On Apr 20, 2006, at 2:31 AM, Olivier Delannoy wrote:
>
> > No it's not better because if you have several constructors, the
> > initial state of the object does not have to be defined several time,
> > one time globally and one time in the constructor. In the case of
> > complex object, creating a temporary unused object is not interesting.
> > The constructor is the place where you should initialize object
> > states. The current way to do stuff is the more efficient way for C++.
> >
>
>