I have create a library, where one parent class is exposed to the user, and then there are other classes which are private, and being used by the parent class.
All these sub-classes most be able to use shared data from the parent class, such as array of floats, and pointers ,which can't be passed as arguments, because there are many of them.
What would be the best practice to make shared variables between them all, and keep them alive ?
The only way I see, is a singleton, which I don't know how to create in C++ .
But why? A sensible division of functions and variables among the classes should make this unnecessary. If the 'parent' has a data area that one of the children needs to work on, then just pass the address of the data instead of copying the data.
A good example is Serial.write(char *buf, int len) which writes out a number of characters from a given buffer. It doesn't copy the buffer. That buffer can be local (private) to any function and all the write() function has is the starting address and the length.