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

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -