Warning this will be initialized after that - c++

This is a discussion on Warning this will be initialized after that - c++ ; What causes this kind of warning to occur? why is the compiler forcing some order of initialization in an initializer list? I frequently run into this when I am initializing a pointer and an int in a constructor's initializer list....

+ Reply to Thread
Results 1 to 4 of 4

Warning this will be initialized after that

  1. Default Warning this will be initialized after that

    What causes this kind of warning to occur? why is the compiler forcing
    some order of initialization in an initializer list?
    I frequently run into this when I am initializing a pointer and an int
    in a constructor's initializer list.

  2. Default Re: Warning this will be initialized after that

    * Christopher:
    > What causes this kind of warning to occur? why is the compiler forcing
    > some order of initialization in an initializer list?


    The language requires that sub-objects (bases and data members) are
    initialized in the order they are declared. The order specified in an
    initializer list does not matter. A compiler may warn you that you will
    not get the order you have used in an initializer list.

    To avoid such warnings, use the declaration order in every initializer list.


    Cheers, & hth.,

    - Alf

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?

  3. Default Re: Warning this will be initialized after that

    Christopher wrote:
    > What causes this kind of warning to occur? why is the compiler forcing
    > some order of initialization in an initializer list?
    > I frequently run into this when I am initializing a pointer and an int
    > in a constructor's initializer list.


    Class members are initialised in the order they are declared, not the
    order they appear in initialiser lists.

    --
    Ian Collins.

  4. Default Re: Warning this will be initialized after that

    In article <eb44f11c-ce55-49d7-b0eb-57f8c4c3a96d@i29g2000prf.googlegroups.com>,
    Christopher <cpisz@austin.rr.com> wrote:
    >What causes this kind of warning to occur? why is the compiler forcing
    >some order of initialization in an initializer list?
    >I frequently run into this when I am initializing a pointer and an int
    >in a constructor's initializer list.


    Check out http://www.comeaucomputing.com/techtalk/#meminit
    --
    Greg Comeau / 4.3.9 with C++0xisms now in beta!
    Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
    World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
    Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

+ Reply to Thread