C++ How to define array of objects (Eclipse arduino) -


going nuts trying define array of objects. thanks.

// menu.h #ifndef menu_h_ #define menu_h_ #include "wstring.h" class menu { public:     menu(string label);     void addchild(string label);     string getlabel(); private:     menu  childmenus[10]; ==> field 'childmenus' has incomplete type 'menu [10]     string label; }; #endif /* menu_h_ */ 

you have object within object class. menu should not use in itself.

you use array of object pointers, should work:

menu* childmenus[10]; 

you access childmenus array so:

childmenus[0]->getlabel(); 

Comments

Popular posts from this blog

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -

php - Autoloader issue not returning Class -