Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Thinking in C++
Prev Contents / Index Next

What to do

There are three approaches to dealing with this problem:

  1. Don’t do it. Avoiding static initialization dependencies is the best solution.
  2. If you must do it, put the critical static object definitions in a single file, so you can portably control their initialization by putting them in the correct order.
  3. If you’re convinced it’s unavoidable to scatter static objects across translation units – as in the case of a library, where you can’t control the programmer who uses it – there are two programmatic techniques
    Thinking in C++
    Prev Contents / Index Next

 
 
   Reproduced courtesy of Bruce Eckel, MindView, Inc. Design by Interspire