How do I create an array of objects from a custom made library?

I just watched a tutorial on Youtube on how to create an array of objects. Wasn't too helpful.

Heres PixelLib.h:

#ifndef pixel
#define pixel

#if (ARDUINO > 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class PixelLib {
public:
PixelLib(int x, int y, int amp);
PixelLib();

void scroll();
int getX();
int getY();
int getAmp();

private:
int x;
int y;
int amp;
};
#endif

Heres PixelLib.cpp

#include "Pixel.h"

PixelLib::PixelLib(int x, int y, int amp) {
}

PixelLib::PixelLib() {
x = 0;
y = 0;
amp = 0;
}

void PixelLib::scroll() {
x++;
}

int PixelLib::getX() {
return x;
}

int PixelLib::getY() {
return y;
}

int PixelLib::getAmp() {
return amp;
}

I'm trying to create an array of PixelLib objects in this line of code in my sketch:
PixelLib pixels[256];

I'm not getting an error there though. I'm getting in error in PixelLib.cpp. It says prototype for 'PixelLib::PixelLib()' does not match any in class 'PixelLib'. I'm pretty sure it's saying the signatures for the empty constructors are different, but I don't see how.

#include "Pixel.h"

Shouldn't that be:

#include "PixelLib.h"

To create the array as you're trying to do, the class MUST contain a constructor that takes no arguments to initialize those objects. That is what the error message is telling you - it tries to call the constructor PixelLib::PixelLib(), but you didn't define one.

Regards,
Ray L.

edp445s_mustache:
I just watched a tutorial on Youtube on how to create an array of objects. Wasn't too helpful.

Surprise, surprise.

RayLivingston:
To create the array as you're trying to do, the class MUST contain a constructor that takes no arguments to initialize those objects. That is what the error message is telling you - it tries to call the constructor PixelLib::PixelLib(), but you didn't define one.

I see this one:

PixelLib::PixelLib() {
  x = 0;
  y = 0;
  amp = 0;
  }

Definitely need

#include "PixelLib.h"

instead of #include "Pixel.h"

Note that

PixelLib::PixelLib(int x, int y, int amp) {
}

does not initialize your instance variables. Ideally name the parameters differently and either initialize the variables in the body of the constructor or use a member initializer list