Hi-
I created a Sensor class so I can instantiate several types of sensors, each of which samples an analog-in pin on the Mega and stores some of these samples in a private array. The problem is that I'd like to instantiate some Sensor objects w/ a sample history array size of 6 samples, and other's with sample history array size of 50 samples. How can I accomplish this feat in the constructor (or wherever else), if the Arduino compiler requires (as specified in C++ standard) that C++ classes to have all arrays defined by constants, since space is allocated at compile-time? If I use a variable, I get the "array bound is not an integer constant" error.
I essentially want to call new Sensor(5) or Sensor(40) and have it create private arrays of 5 and 40, respectively, to store the sampled values.
I've been scanning the net, and I'm completely confused by the posts regarding variable-length Arrays in C++. Some say new C++ syntax allows for Variable Length Array (Why aren't variable-length arrays part of the C++ standard? - Stack Overflow) and others suggest using something called a std::vector. What is the easiest way to essentially maintain a sample history in a class.
Thanks,
Don