I am trying to pass a multidimensional array into a function. The array looks something like this:
const char CHECKERS_ANIMATION[][8] = {
{0xcc,0xcc,0x33,0x33,0xcc,0xcc,0x33,0x33},
{0x33,0x33,0xcc,0xcc,0x33,0x33,0xcc,0xcc}
};
I have bunch of these arrays. They are all Nx8 where N is known at compile time.
In my class header file I have a public method defined as such:
template <typename T, size_t frames, size_t rows> void playAnimation(int device_number, const T (&animation)[frames][rows], int iterations = 1, int speed = 50000);
The implementation of this method:
template <typename T, size_t frames, size_t rows> void LEDMatrix::playAnimation(int device_number, const T (&animation)[frames][rows], int iterations, int speed)
{
cout << "r: " << rows << ", f: " << frames << endl;
for (int i = 0; i < iterations; i++) {
for (int j = 0; j < frames; j++) {
for (int k = 0; k < rows; k++) {
putRow(device_number, k, animation[j][k]);
}
usleep(speed);
clearDisplay(device_number);
}
}
}
The method is called as such:
obj->playAnimation(0, CHECKERS_ANIMATION);
I picked this approach, because I need to know the NxM size of the array inside the method.
When I compile this I get the following error:
/tmp/ccMH2CBE.o: In function `main':
test.cpp:(.text.startup+0x44): undefined reference to `void LEDMatrix::playAnimation<char, 13u, 8u>(int, char const (&) [13u][8u], int, int)'
collect2: ld returned 1 exit status
How can I resolve this? I have already killed two days trying to solve what I think is a simple problem.
Thank you.
Aucun commentaire:
Enregistrer un commentaire