Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #12179

Re: own initialization before calling parent's constructor

From Bart v Ingen Schenau <bart@ingen.ddns.info>
Newsgroups comp.lang.c++
Subject Re: own initialization before calling parent's constructor
Date 2011-12-08 16:09 +0100
Organization No organisation in particular
Message-ID <jbqjv4$7h4$1@localhost.localdomain> (permalink)
References <ebf5a2e8-c94a-4380-b21f-045cf5314fa5@j10g2000vbe.googlegroups.com>

Show all headers | View raw


avasilev Wrote:

> Hello,
> The subject says it - is it legal to initialize fields of the derived
> before calling the parent's consctructor, in the initialization list.

It is immaterial if it is legal or nor, because it is impossible.
The order of initialisation of a class's base-classes and members is not
dependent on the order they are specified in in the initializer-list, but
rather the order they are declared in in the class's definition.

If you compile your example with g++, with the warning flags -Wreorder or
-Wall, then g++ will complain that the initialization order is different
from the order in your initializer list.

> Greetings
> Alex

Bart v Ingen Schenau

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 05:07 -0800
  Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 09:03 -0500
    Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 08:12 -0800
      Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 12:04 -0500
  Re: own initialization before calling parent's constructor Bart v Ingen Schenau <bart@ingen.ddns.info> - 2011-12-08 16:09 +0100
    Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 08:10 -0800
      Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 12:05 -0500
        Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 10:22 -0800
          Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 13:44 -0500
          Re: own initialization before calling parent's constructor Gert-Jan de Vos <gert-jan.de.vos@onsneteindhoven.nl> - 2011-12-08 10:51 -0800
            Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 14:04 -0500
            Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 11:07 -0800
            Re: own initialization before calling parent's constructor Stuart Redmann <DerTopper@web.de> - 2011-12-09 05:43 -0800
          Re: own initialization before calling parent's constructor Goran <goran.pusic@gmail.com> - 2011-12-08 11:09 -0800
            Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 11:34 -0800
              Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 15:15 -0500
              Re: own initialization before calling parent's constructor Goran <goran.pusic@gmail.com> - 2011-12-09 00:07 -0800
                Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-09 05:54 -0800
      Re: own initialization before calling parent's constructor Kevin McCarty <kmccarty@gmail.com> - 2011-12-08 09:27 -0800
        Re: own initialization before calling parent's constructor avasilev <alxvasilev@gmail.com> - 2011-12-08 10:40 -0800
          Re: own initialization before calling parent's constructor Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-08 13:55 -0500
          Re: own initialization before calling parent's constructor Kevin McCarty <kmccarty@gmail.com> - 2011-12-08 12:41 -0800
      Re: own initialization before calling parent's constructor jgk@panix.com (Joe keane) - 2011-12-08 21:20 +0000
  Re: own initialization before calling parent's constructor Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-08 11:17 -0600
  Re: own initialization before calling parent's constructor Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-12-08 16:42 -0500

csiph-web