initialize a vector in a constructor

I will definitely vote for dynamic allocation. Seems a lot cleaner than templates for ints. (Although I will apologize in advance if this needs tweaks to compile on the stock Arduino avr-gcc... I should keep a copy of old compilers just to make sure my forum posts still compile :slight_smile: )

After the constructor is finished, you never have to think about myVector as a pointer. Just treat it like an array, except don't use sizeof() on it.

class myClass
{
private:
  int N_ELEMENTS;
  unsigned long *myVector;
public:
  myClass(int N_ELEMENTS=20)
  {
    myVector = new unsigned long[N_ELEMENTS];
  }
  ~myClass()
  {
    delete[] myVector;
  }
};