I am making my own library, but I don't know how to make array goes well.

I am trying to make an array to hold object in .cpp and .h file, but it doesn’t work. Does any one could help me with it? Here is the code.
.h file

#ifndef MENU_H
#define MENU_H

#include "Arduino.h"

class Menu
{
public:
  Menu(String title, int arraySize, Menu menu[]);
private:
  String _myTitle;
  int _myArraySize;
  Menu _myItems[];
};
#endif

in .cpp file

#include "Menu.h"
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdlib.h>

Menu::Menu(String title, int arraySize, Menu menu[])
{
  _myTitle = title;
  _myArraySize = arraySize;
  _myItems[] = menu[];
}

Here is the error message:

In file included from Menu.cpp:8:
Menu.h:21: error: field ‘_myItems’ has incomplete type
Menu.cpp: In constructor ‘Menu::Menu(String, int, Menu*)’:
Menu.cpp:17: error: ‘_myItems’ was not declared in this scope
Menu.cpp:17: error: expected primary-expression before ‘]’ token
Menu.cpp:17: error: expected primary-expression before ‘]’ token

I think it's fair to say that you have a long road ahead of you with C/C++. Writing libraries is only possible when you are proficient in the language. What you wrote has multiple mistakes.

In .h file you attempt to define an object array without a dimension. You can't define a c array with no dimensions unless there is initializer indicating the dimension. In .cpp you attempt to assign an array to another array. This will never work in C world. Never is too absolute but I should not further confuse you with operator overload in C++.

To solve your problems, you should define myitems as a pointer to pointer so you can later assign address of a Menu object pointer array to it in the constructor.

I suspect your inclusion of Menu array in object is to construct a tree. You don't store the leaves in an object, just pointers to leaves.

Thanks, but it's not helpful enough to a hardware programing beginner. :stuck_out_tongue_closed_eyes:

If you can't understand language like pointer to pointer and need a code sample to digest with, I wish not to help you do your library. You need to get it yourself first. Writing library is a responsibility and liability. It is not for beginners with basic c language questions. You are way over your head. Arduino makes programming easy but there is still a limit on what you can do on your first couple of days/weeks/months with it. If you really want to write libraries NOW, why don't you read a few included libraries to see how much you can understand? There you go, a solid example. Read EEPROM library first, it is the simplest. Then take your pick, liquidcrystal or Print etc.

FYI, all my first reply was solid suggestion. Not being able to put it into code just shows you are not up for the library task. Why struggle at the wrong level while you can learn at the right one? Ambition? Over confidence?

well!! thank you for trying to be helpful. The rest of this library is not finished yet, array issue is just a small portion of this project. I haven't done any C++ programming for a while. The things I am doing right now is trying to do something to get my memory back. Since you have being doing C/C++ for your whole entire life. Have you every feel kind of forget or stuck in a small thing? When people help you with coding a little bit, and then you will never forget how to do it and never forget how helpful that person is.

You've probably seen this (it doesn't say much) but here it is anyway: http://arduino.cc/en/Hacking/LibraryTutorial

[quote author=Mike Lo link=topic=180274.msg1336269#msg1336269 date=1375237477] array issue is just a small portion of this project. [/quote]

If you could make a Menu object that includes Menu objects then they would include menu objects that would include other Menu objects, etc till memory runs out.

Just to knock some of the rust off, you should make a number of the examples work even if the code seems familiar. if you remember coding then you know that close won't cut it.

In your IDE under File is Examples. Do and learn/relearn at least the following: File->Examples->02. Digital->BlinkWithoutDelay File->Examples->05. Control-> go through all of these to tighten yourself back up

Other examples; Forget plain old Blink, it teaches the bad habit of using delay(). The rest, do what interests you or you have questions about. Some need extra hardware.

Everything that uses C++ String objects, convert to C char array strings. If you never knew C strings (lower case s) then find a string.h tutorial on the web, if you lock yourself into using String objects then you won't get as much help when they start crashing your sketches. UNO has only 2k RAM, Leo 2.5k. String objects waste and shotgun your heap in RAM. Here are the standard C libraries docs for AVR GCC that Arduino uses, including string.h: http://www.nongnu.org/avr-libc/user-manual/modules.html