467,879 Members | 1,087 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,879 developers. It's quick & easy.

How to make a value visible to anywhere in my app?

Hi, I'm still getting my head around programming with classes and I'm confused about something.
A have a class member that's set when I create an object. But my application has several other classes that I want to be able to see the value of this member and the only way I can think of to do that is by passing the member value as a parameter for the other class function that I want to be able to see the value.

Is this the right way to do it? It doesn't look neat and if I have several values to be shared then my functions will start to have too many parameters.
Any advice?
Thanks a lot.
Nov 20 '06 #1
  • viewed: 1178
Share:
4 Replies
1GB
Hi, I'm still getting my head around programming with classes and I'm confused about something.
A have a class member that's set when I create an object. But my application has several other classes that I want to be able to see the value of this member and the only way I can think of to do that is by passing the member value as a parameter for the other class function that I want to be able to see the value.

Is this the right way to do it? It doesn't look neat and if I have several values to be shared then my functions will start to have too many parameters.
Any advice?
Thanks a lot.
Hi. There are some things that you can do to make the value of this class member available to the rest of your app. However...
When you design a class it is important to think through encapsulation. If your other classes require this value then it seems logical that you should merge the classes together as they share functionality.

The value can be stored in a global variable but that will still present the same problems in having to pass it to your other objects and it destroys encapsulation.
Nov 20 '06 #2
Hi. There are some things that you can do to make the value of this class member available to the rest of your app. However...
When you design a class it is important to think through encapsulation. If your other classes require this value then it seems logical that you should merge the classes together as they share functionality.

The value can be stored in a global variable but that will still present the same problems in having to pass it to your other objects and it destroys encapsulation.
That's what I thought. The value I want to share is a language attribute that will tell different procedures in my application to use "Bonjour" instead of "Hello", for example. So I created an object that stores all the terms in the language the user chose to use. All I want is for this object to be visible anywhere in my app. There's just too much funcitonality to merge in the same class I think.
Nov 20 '06 #3
100+
That's what I thought. The value I want to share is a language attribute that will tell different procedures in my application to use "Bonjour" instead of "Hello", for example. So I created an object that stores all the terms in the language the user chose to use. All I want is for this object to be visible anywhere in my app. There's just too much funcitonality to merge in the same class I think.
hi

have you tried a res-file wihin your project?

call data from there with
something like:
Form1.Sample.Caption = LoadResString(20 + Var)
Nov 21 '06 #4
1GB
That's what I thought. The value I want to share is a language attribute that will tell different procedures in my application to use "Bonjour" instead of "Hello", for example. So I created an object that stores all the terms in the language the user chose to use. All I want is for this object to be visible anywhere in my app. There's just too much funcitonality to merge in the same class I think.
You will find plenty to read about this right here
Nov 21 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

19 posts views Thread by zzw8206262001 | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.