Hi there!
Lets say I have this pseudo dummy code:
CustomItem * item1();
CustomItem * item2();
CustomItem * arrItems[10];
arrItems[0] = item1;
arrItems[1] = item2;
Whats the actual memory allocation of the array "arrItems"?
- Is it sizeof(CustomItem) * 10?
- Is it just the size of the pointer to the members? So 20 bytes (one pointer 2 bytes on the ATMega328, right?)?
- sizeof(CustomItem) * 2? Because I added only 2 CustomItems?
- Pointer * 2? Because I added only 2 pointers?
Just asking because I want to be more aware of my memory allocation habbits! 
Thanks in advance!
- None of the above.
The code is nonsensical. item1 and item2 are functions that take no arguments and return a pointer to a CustomItem. But, arrItems is an array of pointers to CustomItem. So, the assignments statements are illegal. They are also outside of any function, causing another compiler error.
Depending on your actual intent, you either need this:
CustomItem * item1();
CustomItem * item2();
CustomItem * arrItems[10];
void setup() {
arrItems[0] = item1();
arrItems[1] = item2();
}
void loop() {
}
Or This:
CustomItem * item1();
CustomItem * item2();
CustomItem * (*arrItems[10])();
void setup() {
arrItems[0] = item1;
arrItems[1] = item2;
}
void loop() {
}
That is, assuming you go on to define item1() and item2() somewhere.