advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Which additional problems can the technique demonstrated here solve? Which problems, if any, does it create? Post your suggestions in the c++.general discussion group.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 4.7/5 | Rate this item | 3 users have rated this item.
 

Managing Objects' Construction Order

Standard C++ doesn't specify the initialization order of objects with static storage type. Using the accessor function will ensure that objects in separately compiled files are constructed in the correct order.  


advertisement
n standard C++, the initialization order of objects with static storage type that are declared in separate translation units is unspecified. If, for instance, a constructor of object A takes as an argument a value returned from a member function of object B, B must be constructed before A. However, if A and B are defined in separately compiled files, there's no guarantee that B will be constructed first.


How can you ensure that objects defined in separately compiled files are constructed in a desired order?


Avoid global objects. Use special accessor functions instead.

  Next Page: Advice on Code Organization
Page 1: IntroductionPage 3: Dealing with the Construction Order Dependency
Page 2: Advice on Code Organization  
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs