I was successfully to finally be able to use TUI header from PDcurses library in my C++ project in a previous post here.
now in my class I am including the C header:
#include "tui.h"
tui is in C and has this definition for menu:
typedef struct
{
char *name; /* item label */
FUNC func; /* (pointer to) function */
char *desc; /* function description */
} 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");
}
this is working as expected.
The problem is that i need to make calls on my class methods in sub0() and sub1().
I tried to define 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 is throwing 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 of passing those function pointers to the C code and get rid of that error?
thanks