Class for variables...
Posted on 2000-03-02
Hi, I have a dialog based app with a button that opens a property sheet with four pages. The dialog box, property sheet and each of the four pages have their own class. The purpose of the porperty pages is to change and alter variables that are displayed on the dialog box. At the moment I pass the variables to the property sheet class, and then to the respective pages. Naturally this is not pretty because I have about thirty variables. I have heard that it is possible to define a new class, called perhaps variables, and define all my variables in this class. If I need the variables in any other class, I can just access it. Thus there si only one variable in the new class and it is used by the dialog box class, property sheet class and property pages classes. I am struggling in my attempts to implement this. I initialise the class in the dialog based app as the app starts, in the header file in public,
and then I use the variables in the dialog box class like this,
var.testvar = 10;
This semi works well. But to access these variables now in the property pages is troubling. If I initialise an instance of the class in the property pages header file such as I did in the dialog header file, it creates a new instance of the variables class, and none of the variables that I gave values to in the dialog box class are carried through to the property pages class. So what should I do? What is the best way to do it? Basically, I need a technique that is smart, cunning and professional. Thanks.