Define array of custom objects from the same library?

I've created 2 classes in the same library.
In my second class i want to declare a array of my first class (A). How can i do this in c++?

#ifndef AB_h
#define AB_h

#define ARRAY_SIZE 10;
class A
{
public:
	A(void); //Constructor
private:

};

class B
{
public:
	B(void); //Constructor
private:
        A myArray[ARRAY_SIZE]; // <-- Array of Class A objects.
};

One error here:#define ARRAY_SIZE 10; no ; at end required #define ARRAY_SIZE 10

This for me compile, I don't know if work:

#define ARRAY_SIZE 10
class A
{
public:
	A(void) {}; //Constructor
private:

};

class B
{
public:
	B(void) {}; //Constructor
private:
        A myArray[ARRAY_SIZE]; // <-- Array of Class A objects.
};

B myB;

void setup(){}
void loop(){}

oh, my bad! Thanks for the correction.

I still have trouble, but it is in the .cpp file now.

In class B constructor i'm trying to initialise the array of A objects without any luck.

LEDLamps.cpp: In constructor 'LEDLamps::LEDLamps(int8_t, int8_t, int8_t)':
LEDLamps.cpp:66: error: no matching function for call to 'Wave::Wave()'
LEDLamps.cpp:14: note: candidates are: Wave::Wave(int, int, int, int, int)
LEDLamps.h:23: note:                 Wave::Wave(const Wave&)

Here are some of my real code, might be easier to help then.
h file:

static const int numberOfWaves = 20;

// ------------------------------------------------------------------------------------------- //
class Wave
{
public:
	Wave(int speed, int blockSize, int ledCount, int lightness,int startCount); // Constructor

private:

};

// ------------------------------------------------------------------------------------------- //
class LEDLamps
{
public:
	LEDLamps(int8_t lampCount, int8_t dataPin, int8_t clockPin);
	
private:
	Wave waveArray[numberOfWaves];
};

My .cpp code, in Class B (LEDLamps) constructor i'm trying to initialise Class A (Wave) object to the array.

Wave::Wave(int speed, int blockSize, int ledCount, int lightness, int startCount)
{ 
           // Doing some stuff...
}

// ------------------------------------------------------------------------------------------- //
LEDLamps::LEDLamps(int8_t lampCount, int8_t dataPin, int8_t clockPin)
{ 
        int i;
	for (i = 0; i < numberOfWaves; i++) {
		waveArray[i] = Wave(10,2,25,150,100);
	}
}

What i understand from that error message the parameters are wrong but i'm sending 5 integer and constructor is defined to receive 5 integer? So i must be doing something else wrong...

[quote author=thedruid link=topic=212411.msg1556995#msg1556995 date=1390345749]
In class B constructor i'm trying to initialise the array of A objects without any luck.
[code]LEDLamps.cpp: In constructor 'LEDLamps::LEDLamps(int8_t, int8_t, int8_t)':
LEDLamps.cpp:66: error: no matching function for call to 'Wave::Wave()'
LEDLamps.cpp:14: note: candidates are: Wave::Wave(int, int, int, int, int)
LEDLamps.h:23: note:                 Wave::Wave(const Wave&)

[/code]
[/quote]

The error msg is very clear. When you declare the array in LEDLamps you need to use the constructor without parameters.
So compiler ask you to write a constructor Wave::Wave(void)
I don't know if you can declare array of object and also pass parameters to the right constructor.
I think you can't declare something like this: Wave waveArray[numberOfWaves](1,2,3,4);

So you can create an array of pointers to wave objects and populate only when you really need this objects.
When you create (at runtime) one new wave object you can call the right constructor and assign the pointer to one element of the array.

Maybe it will help others:

in the documentation of the Moodlight library it says you need to put:

// create MoodLight object
MoodLight ml = MoodLight();

BEFORE setup(){...}

So in order to create an array of 3 Moodlight objects I created them like this:

MoodLight led[3];

And then:

void setup() {
for (int i=0; i<numLeds; i++){
led = MoodLight();

  • }*
    }

in the documentation of the Moodlight library it says you need to put:

// create MoodLight object
MoodLight ml = MoodLight();

Well, the documentation is wrong, then.

MoodLight ml;

is the correct way to create an instance of the class.

Creating an array of MoodLight objects:

MoodLight lotsOfThem[10];

NO other action is needed.

So you made a class Wave with only a constructor that takes arguments. So, or make a constructor without argument, or give the arguments when constructing.

Wave myWave[2] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};
Wave allTheSameWave[10] = Wave(1, 2, 3, 4 ,5);

You can initialise an array in a constructor, but the syntax is extremely nasty. You are better off having a no-argumant constructor for the objects in the array, and an initialisation method that you call in a loop.