Noob (and a hobbyist) hobbyist question.
I have a class library that I can feed instances of with data from arrays and structures by indexing through those arrays, but I can't for the life of me find a simple way to also index each instance of the class.
What I'm having to do is instantiate discrete instances
#include <myclass.h>
Instantiate each class for each button
myclass class0; .. myclass classN;
Then I have to manually populate an array with the results of all the tests
bool myTests[] {class0.result(),class1.result(),..,classN.result()};
before I can use the test results in digitalWrite() calls to outputs.
I'd really like to be able to instantiate my methods sort of like an array and just iterate over the methods at the same time as I'm iterating over the outputs the results are for.
AFAIKT, the Arduino platform doesn't do vectors, although I'm not entirely sure that's the "droid" I'm looking for, either.
Anybody got a basic idea of how to do this at my nuts-and-bolts/beginnerish level?
Using platformIO with Arduino platform.
I've tried instantiating as an array,
for(int i = 0; i < N; i++){ myclass myinstance[i]; }
Of course, that was an epic fail. It's OK to laugh, I figured it wasn't going to work.
Tried to access vectors, nup, not on the Arduino platform, IDE or PIO.
Tried some things that, in hindsight are too stupid to mention, from what I've read while googling my brains out.
And, yep, I've googled this for maybe four hours, and I'm convinced I don't even know enough about this sort of thing to get my search terms right. Also poured over this venerable site, as is often my first resort.
Surely the gods of C++ have an elegant solution for this? Maybe kindly steer me to a tutorial and kick my bum as I head off there...
Cheers Crunchy
Your question is not very clear, but does something like this give you a hint or a way to move forward?
Also from a quick Google search it looks like there is a Vector library that you can install for Arduino.
But this is all rather basic C++, so I think you may also get a lot out of just reading a good C++ book.