Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Ctor/Dtor order

Reply
Thread Tools

Ctor/Dtor order

 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      07-30-2003


shura wrote:
>
> Hi!
>
> Situation:
>
> class A
> {
> B m_B;
> C m_C;
> };
>
> Can I assume that for all C++ compilers
> the order of subobjects creation is:
> m_B first then m_C.
> and the order of destruction is
> m_C first then m_B.


yes. Thats how it is defined to be.

--
Karl Heinz Buchegger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-30-2003
"shura" <(E-Mail Removed)> wrote...
> Situation:
>
> class A
> {
> B m_B;
> C m_C;
> };
>
> Can I assume that for all C++ compilers
> the order of subobjects creation is:
> m_B first then m_C.
> and the order of destruction is
> m_C first then m_B.


I don't think it's good to _assume_, but the order
you describe is required by the Standard. So, all
Standard-compliant compilers should do it that way.

Victor


 
Reply With Quote
 
 
 
 
shura
Guest
Posts: n/a
 
      07-30-2003
Hi!

Situation:

class A
{
B m_B;
C m_C;
};

Can I assume that for all C++ compilers
the order of subobjects creation is:
m_B first then m_C.
and the order of destruction is
m_C first then m_B.
 
Reply With Quote
 
Greg Comeau
Guest
Posts: n/a
 
      07-30-2003
In article <bg8d23$dk4$(E-Mail Removed)>,
shura <(E-Mail Removed)> wrote:
>Situation:
>
>class A
>{
> B m_B;
> C m_C;
>};
>
>Can I assume that for all C++ compilers
>the order of subobjects creation is:
> m_B first then m_C.
>and the order of destruction is
> m_C first then m_B.


Yes. Of course, B may have its own subobjects and so on.
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
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 With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If you get an order # does it mean the order is accepted? =?Utf-8?B?U3RldmUxMDc3?= Windows 64bit 3 05-12-2005 11:46 PM
Two nics, change access order in REGISTRY key?? =?Utf-8?B?TWFjY2E3Nw==?= Wireless Networking 1 01-01-2005 08:32 PM
Traversion order cf. output order in XSL Soren Kuula XML 2 02-01-2004 09:10 AM
In which order are files looked for when loaded/requierd - and what'sthe order of suffixes? Stephan Kämper Ruby 2 01-18-2004 02:07 PM
How to Display DropDownList with preserved order (custom order) cspoh ASP .Net Web Controls 0 07-31-2003 09:19 AM



Advertisments