Thanks, Will, for your kind explaination.
In my case, I was thinking of a data pool (status, global configuration
data), which different modules of my program will have access to, some may
update the data, some may only retrive the data for various purposes, some
might read and write to the data pool. If not using global objects, what do
you think would be the best solution to it?
Thanks and regards,
Cate
> > Hi, I am new to C++ from C, I am a bit confused about using global objects
> > in
[quoted text clipped - 27 lines]
> Regards,
> Will
Peteroid - 25 Mar 2005 02:04 GMT
Just jumping in with a comment. If you do decide to use global variables, I
recommend putting them in their own namespace[s]. That way any naming
conflicts will be resolved and/or easy to discover...
[==Peteroid ==]
> Thanks, Will, for your kind explaination.
>
[quoted text clipped - 44 lines]
>> Regards,
>> Will
MechSoft - 27 Mar 2005 21:43 GMT
Thank you for your kind suggestion.
Regards,
Cate
> Just jumping in with a comment. If you do decide to use global variables, I
> recommend putting them in their own namespace[s]. That way any naming
[quoted text clipped - 50 lines]
> >> Regards,
> >> Will
William DePalo [MVP VC++] - 25 Mar 2005 04:30 GMT
> Thanks, Will, for your kind explaination.
You are welcome.
> In my case, I was thinking of a data pool (status, global configuration
> data), which different modules of my program will have access to, some may
> update the data, some may only retrive the data for various purposes, some
> might read and write to the data pool. If not using global objects, what
> do
> you think would be the best solution to it?
Well, the devil is _always_ in the details. The data pool sounds like it
might be implemented as a class with methods to query and modify the data.
Rather than a global, you might want to look at the "singleton pattern". It
is what you use when you need exactly one instance of a class.
Just by the way, theses groups are a good source of information on specific
topics, especially when you have a specific question. And if you haven't
heard the terms "singleton" or "pattern" before it can serve as something to
start a search on google which eventually winds up in Barnes and Noble or
Borders or the bookstore at a local university. But there is no substitute
for quiet research and experimentation.
Regards,
Will
MechSoft - 27 Mar 2005 17:03 GMT
> Well, the devil is _always_ in the details. The data pool sounds like it
> might be implemented as a class with methods to query and modify the data.
Yes, only use methods to change and query data.
> Rather than a global, you might want to look at the "singleton pattern". It
> is what you use when you need exactly one instance of a class.
[quoted text clipped - 5 lines]
> Borders or the bookstore at a local university. But there is no substitute
> for quiet research and experimentation.
Thank you very much. I did some reading after reading your post and founf
this topic very interesting. You have been of great help to my issue. Thanks
a lot!
Regards,
Cate