Once again I apologize for the noobish question, but I haven't really worked with pointers much and I'd like some help.
I want pass a variable to a class instance on initialization and then have it monitor the value of that variable without having to pass it again each time step. I know that this is possible through pointers but am having a bit of trouble with the implementation.
"double *value" is a member of my "cockpit gauge" class whos' initializer looks like this...
My understanding from reading of the c++ documentation was that If I initialized the class in my vessel's code as follows...
that "Gauge1.value" and "MyVessel.press_kpa" would be effectively linked but in practice this does not seem to be the case as changes in the value of "press_kpa" on the vessel side are not being reflected by "value" on the Gauge side.
Any help would be greatly appreciated.
I want pass a variable to a class instance on initialization and then have it monitor the value of that variable without having to pass it again each time step. I know that this is possible through pointers but am having a bit of trouble with the implementation.
"double *value" is a member of my "cockpit gauge" class whos' initializer looks like this...
Code:
Gauge1::Gauge1(VESSEL3 * v, double *val)
{
value = &val;
//...plus other stuff getting initialized
}
My understanding from reading of the c++ documentation was that If I initialized the class in my vessel's code as follows...
Code:
pressuregauge = new Gauge1(this, &press_kpa); // "pressuregauge" and "press_kpa" are both members of my vessel class
that "Gauge1.value" and "MyVessel.press_kpa" would be effectively linked but in practice this does not seem to be the case as changes in the value of "press_kpa" on the vessel side are not being reflected by "value" on the Gauge side.
Any help would be greatly appreciated.