I've been developing a library and I would like to add a static member to the library. I'm a bit rusty on C++ and have been using mostly Java.
In Java it's quite straight forward as the code is incorporated into the class, however it seems that with Arduino the implementation and definition must be seperate.
I've searched around but not found a complete example that works for me.
In my class I would like to add a static pointer to another object type, I prefixed the declaration with the keyword static.
When I reference the member I prefix the member with the class name and '::' instead or '.'
For example:
class clsDemo {
private:
static Adafruit_NeoPixel* mpobjNeoPixels;
static uint8_t mu8NumPixels;
...
static void setNeoPixels(Adafruit_NeoPixel* pobjPixels, uint8_t u8NumPixels);
}
Then in the class itself I have the implementation of the function:
void clsDemo::setNeoPixels(Adafruit_NeoPixel* pobjPixels,uint8_t u8NumPixels) {
mpobjNeoPixels = pobjPixels;
mu8NumPixels = u8NumPixels;
}
When I try to compile this I errors to undefined references for 'clsDemo::mpobjNeoPixels' and 'clsDemo::mu8NumPixels'.
Can anyone show me the correct syntax?
Thank you