Closed kamze closed 7 years ago
Hi! You can't instantiate classes like that in the member listing of a class in C++.
Try just having MenuBackend menu; in the header, then instantiate it with an instantiation list in the constructor of your GPSMenu class something like:
GPSMenu::GPSMenu(LiquidCrystal* lcd) : menu(menuUseEvent, menuChangeEvent) {
and then declase menuUseEvent and menuChangeEvent as static void.
Contact me on alexanderbrevig ATSIGN gmail.com if you need further assistence :)
The email server had an error trying to email you so try this: GPSMenu.zip it's using the instantiation syntax for all your member classes.
Sorry it was my engineering school email : This is the same reply i sent you So i tried what u sent there are less errors there is only one remaining error which is repeated u=in several places:
In file included from GPSMenu.cpp:4:0: GPSMenu.h: In static member function ‘static void GPSMenu::menuUseEvent(MenuUseEvent)’: GPSMenu.h:37:20: error: invalid use of member ‘GPSMenu::_lcd’ in static member function LiquidCrystal _lcd; ^ GPSMenu.cpp:52:4: error: from this location _lcd->setCursor(0, 0); ^ In file included from GPSMenu.cpp:4:0: GPSMenu.h:37:20: error: invalid use of member ‘GPSMenu::_lcd’ in static member function LiquidCrystal _lcd; ^ GPSMenu.cpp:53:4: error: from this location _lcd->print(used.item.getName()); ^ In file included from GPSMenu.cpp:4:0: GPSMenu.h:37:20: error: invalid use of member ‘GPSMenu::_lcd’ in static member function LiquidCrystal *_lcd;
2017-06-24 13:06 GMT+02:00 Alexander Brevig notifications@github.com:
The email server had an error trying to email you so try this: GPSMenu.zip https://github.com/WiringProject/Wiring/files/1099609/GPSMenu.zip it's using the instantiation syntax for all your member classes.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WiringProject/Wiring/issues/49#issuecomment-310832229, or mute the thread https://github.com/notifications/unsubscribe-auth/ALmlsGC-O0NRKfa1T01N-FaGu3YYHg-Jks5sHO3FgaJpZM4OECOC .
I am doing a display class using 2*8 lcd on an arduino to display and navigate my menu using MenuBackend library but i can make instance of these variables. I tried using static variable it did not work either.
Here is the code: GPSMenu.h :
GPSMenu.cpp:
Erros i am getting:
is it because of this line MenuBackend menu = MenuBackend(menuUseEvent,menuChangeEvent); since i am calling menuUseEvent & menuChangeEvent here (if i do it without class it works just fine)?