Sign in to follow this  
kelaklub

Global data

Recommended Posts

kelaklub    160
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.

Share this post


Link to post
Share on other sites
kelaklub    160
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]

Share this post


Link to post
Share on other sites
kelaklub    160
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this