> Note that you likely will have unexpected interactions if A::x is > in more than one shared library, and is initialized to a different > value in each.
Point taken. It has not happened thus far that multiple shared libraries with this class in common are installed or loaded on the same system simultaneously. > > > In order keep data appropriately hidden (and save myself some > > bookkeeping), I add this constructor function to various of the shared > > libraries to initialize x to something meaningful (conceptual zero) > > for the given application/environment. > > I still do not understand what the difficulty with simple assignment is. > > Could you provide a simple example demonstrating the need for this > 'constructor function' ? Consider a FilePath class that has a static char* rootDir. By default, you'd expect such a class to have rootDir set to "/" (or "c:\ \" or similar). A particular library may use this class, but want never to go outside the directory "/usr/local/example", or perhaps to be able to easily access said directory without requiring users to type the full path each time. Some other library, for some other system may have a similar requirement for the directory "/opt/example" or "/opt/extra/question_mark". Because different use cases (installations) could have need of a different base path, I find it convenient to set that rootDir at load time, rather than altering the FilePath class and rebuilding it for each case. I'm avoiding rebuilding by setting this path in the 'constructor function' (DllMain in windows) after reading a value from memory some where (registry, environment variable, ...). To be clear, this is an actual scenario where I use this feature in windows, not some contrivance (as we've been working with before), so if there are design suggestions about how to solve this situation, I'd be open to those as well. Thanks jeremy _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus