Skip to main content
2 of 2
deleted 2 characters in body

Passing array to library function

I'm trying to pass an array to a library (written in c++) but the error:

undefined reference to `MyLib::arrayTest(int*)'
collect2: error: ld returned 1 exit status
Error compiling.

Is being produced.

My Code Is As Follows:

Testing.ino:

MyLib test = MyLib(5,4,6);

void setup(){
    int arr[10];

    test.arrayTest(arr);

    Serial.println(arr[0]);
}

MyLib.h:

class MyLib {
    public:
        MyLib(int x, int y, int z);

        void arrayTest(int* n);

MyLib.cpp:

void arrayTest(int* n){
    n[0] = 15;
}

Any help is greatly appreciated :)