I was successfully able to use the TUI header from the PDcurses library in my C ++ project in a previous post here .
now in my class I include the C header:
#include "tui.h"
tui is in C and has this definition for a menu:
typedef struct { char *name; FUNC func; char *desc; } menu;
so in MainView.cpp I have:
void sub0() { //domenu(SubMenu0); } void sub1() { //domenu(SubMenu1); } void MainView::showMainMenu() { menu MainMenu[] = { { "Users", sub0, "Manage Users" }, { "Accounts", sub1, "Manage Accounts" }, { "Items", sub1, "Manage Items" }, { "Staff", sub1, "Manage Staff" }, { "", (FUNC)0, "" } }; startmenu(MainMenu, "Library System 1.0"); }
works as expected.
The problem is that I need to make calls on my class methods in sub0 () and sub1 ().
I tried defining C ++ methods for my class to try and replace sub0 and sub1 with:
void MainView::sub0() { //domenu(SubMenu0); } void MainView::sub1() { //domenu(SubMenu1); }
the compiler sets this error:
error C2440: 'initializing' : cannot convert from 'overloaded-function' to 'FUNC' None of the functions with this name in scope match the target type
What is the best way to pass these pointers to C code and get rid of this error?
thanks