471,066 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

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

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!

Jul 23 '05 #1
1 1148
On 10 Jul 2005 20:22:10 -0700, "user" <b8*******@yahoo.com> 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/~a...FAQ-acllc.html
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Shao Zhang | last post: by
10 posts views Thread by campos | last post: by
5 posts views Thread by Bushido Hacks | last post: by
4 posts views Thread by developereo | last post: by
3 posts views Thread by mweltin | last post: by
15 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.