Howdy all,
I'm fairly new to c++, so I hope this isn't a stupid question. Apologies in advance if that's the case!
I have a struct that looks something like this :
struct config_t
{
unsigned int probe1Value;
unsigned int probe2Value;
}configuration;
I then use the struct in another function like this :
void myFunction(int probe, int value)
{
if(probe==1)
{
configuration.probe1Value = value;
}
else if(probe==2)
{
configuration.probe2Value = value;
}
}
Is it possible to hand the struct member in so I don't have to use the ugly if loop in the function? This is a stripped down version - there are many more values in the full deal, so it's even uglier.
I'm hoping to end up with the function looking something like this :
void myFunction(<whateverthetypeis?> structMember, int value)
{
structMember = value;
}
Any thoughts or different approaches are more than welcomed.
Cheers,
Doug.