I might be going at this wrong but here goes. I have a program with multiple classes, each of which I initialize in main.cpp
I have a data structure that keeps track of the parameters for the program, defined in a file called Defines.h. All classes include this file.
My structure is similar to this.
In main I create a pointer to a params object like:
This all works fine so far. What I want to happen is have this pointerToParams available to all my other classes and where ever it needs it in those classes.
I first thing i did was in each classes initialize function it took a pointer to params as a parameter. This works. Then I made it that each class also has a private pointer variable of prams which I set equal to the passed param pointer.
My problem is when I want to change a variable in the params structure in any class I want the changes to be reflected in all classes. So in short I only want one instance of params to be available anywhere in the program.
Any thoughts,
Thanks for the help.
I have a data structure that keeps track of the parameters for the program, defined in a file called Defines.h. All classes include this file.
My structure is similar to this.
Code:
struct params { int paramone; float paramtwo; };
Code:
params* pointerToParams;
I first thing i did was in each classes initialize function it took a pointer to params as a parameter. This works. Then I made it that each class also has a private pointer variable of prams which I set equal to the passed param pointer.
My problem is when I want to change a variable in the params structure in any class I want the changes to be reflected in all classes. So in short I only want one instance of params to be available anywhere in the program.
Any thoughts,
Thanks for the help.
Comment