sgt_bear:
Its not a must, i just want that my library knows how many values there are in a array. If i pass the lenght, thats also fine. But currently that doesnt work too..
you cannot create an array of length zero and simply add elements as you are trying to do:
private:
uint16_t convFactor;
uint16_t deadTime;
uint32_t pulseCount[];
uint32_t timeInterval[];
uint32_t lastConversion[];
when you try to do this:
lastConversion[i] = 0;
all you are doing is stomping on memory you don't own!
use the template method I showed you to pass the array length... but you need to have a variable that holds that number.
template<uint8_t N>
class MyClass {
private:
uint32_t* myArray;
size_t arrayLength;
public:
MyClass() {
arrayLength = N;
myArray = new uint32_t[arrayLength];
}
size_t getArrayLength (void) {
return arrayLength;
}
};
MyClass<10> myInstance;
void setup() {
Serial.begin(9600);
Serial.println(myInstance.getArrayLength());
}
void loop() {
// put your main code here, to run repeatedly:
}