Global data

Started by
2 comments, last by kelaklub 17 years, 8 months ago
I want to create a collection of global data(such as tolerance values) for a geometric class library I am trying to code. What would be the best way to represent this data? Would the STL map provide a good way to access or write to this data? I don't want the data to be bound to any object of my class but would like a quick way to access it or change it. Any advice would be appreciated. Thanks.
Advertisement
You need to describe more about the intended usage (access/insertion/deletion) patterns for the data.
I would like the data to be accessible to any objects within the library. I guess kinda like state variables that are accessible to objects created for the library, and whose values can be modified but never deleted. One idea came to mind, hear this out...

- Create a class to store all this data.

- Create an object of this class at the global scope to access this data.

- Enforce that no other objects for this class are created by creating a static variable to serve as a counter to make sure that only that one global object can access the data stored in this class.

This is just an idea. So please feel free to shoot it down with constructive criticism. Thanks.

[Edited by - kelaklub on August 20, 2006 10:01:49 AM]
Actually this article has some good ideas under the heading "Const and Data-Hiding". I might check this out too.

http://www.possibility.com/Cpp/const.html

This topic is closed to new replies.

Advertisement