derived class and base class, member assignment, which goes first

Discussion in 'C++' started by user, Jul 11, 2005.

  1. user

    user Guest

    Hi,

    If I assign in the base class' constructor:
    myMember = 5;

    and assign in the derived class' constructor:
    myMember = 10;

    where myMember was derived from the base class,

    I get the result of 10.
    Is this always true, or does it depend on some random state of the
    computer?

    Thanks in advance!
     
    user, Jul 11, 2005
    #1
    1. Advertising

  2. user

    Jack Klein Guest

    On 10 Jul 2005 20:22:10 -0700, "user" <> wrote in
    comp.lang.c++:

    > Hi,
    >
    > If I assign in the base class' constructor:
    > myMember = 5;
    >
    > and assign in the derived class' constructor:
    > myMember = 10;
    >
    > where myMember was derived from the base class,
    >
    > I get the result of 10.
    > Is this always true, or does it depend on some random state of the
    > computer?
    >
    > Thanks in advance!


    It is always true. The base class constructor executes first, then
    the derived constructor.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Jul 11, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl Heinz Buchegger
    Replies:
    3
    Views:
    531
    Karl Heinz Buchegger
    Aug 6, 2003
  2. John Harrison
    Replies:
    0
    Views:
    493
    John Harrison
    Aug 6, 2003
  3. Siemel Naran
    Replies:
    4
    Views:
    809
    Micah Cowan
    Jan 12, 2005
  4. Replies:
    1
    Views:
    397
    myork
    May 23, 2007
  5. Replies:
    1
    Views:
    389
    Victor Bazarov
    May 23, 2007
Loading...

Share This Page