Hi, apologies if this is a dumb question but I’m just starting to learn c++, I’m writing my first library for Arduino, and I’m trying to work something out … all my google searches have failed to get me answers.
I have a class with two members that are arrays of variables, but the size of each array needs to be set by the person using the library.
The array sizes do NOT need to be set at runtime, they can be set at compile time and never changed, so I want to know if there is any clean way to set the array sizes when declaring the object in the sketch without using dynamic memory allocation.
I know I could just use some #define ARRAY_SIZE macros and instruct the user to insert them before declaring the object, but that seems a bit clunky and not very user friendly:
I want something like this:
MyClass myObject(16, 8);
//create myObject containing one 16 element array and one 8 element array
Instead of:
#define ARRAY_1_SIZE 16
#define ARRAY_2_SIZE 8
MyClass myObject;
Is this possible?