A want to get a value of public variable in an instance of a class.
I'm passing an pointer of an instance into Relay. The instance has a boolean deviceState.
class Relay : public Device
{
public:
Relay(uint8_t in_pin, Device *in_dependent_device) {
dependent_device = in_dependent_device;
Serial.print(dependent_device->deviceState);
};
Device *dependent_device;
}
The serial print would yield 129. I'm assuming that's an address and not the value of deviceState which should either be 0 or 1.
I've also tried
dependent_device = &in_dependent_device;
but it also yield another address.
If you can get the value that would be awesome.
thanks.
But then I am not sure why Relay inherits from Device and has the constructor argument in_dependent_device.
You will need to post more code for more answers
The code is too massive to show. I'll write up a simpler model when get the chance. Im getting a headache all of a sudden. Straining too much at the monitor I guess.
I still don't see an actual problem with your original code. If you get '129' and you were expecting something else,
it is possible that the variable that you expected to be 'true' or 'false' wasn't initialized anywhere.
I found the issue. I'm not sure why but declaring it in the base class AND the inherited class made it act funny. I just left it declared in the based class only.