//// In Header
struct PanelTab
{
constchar *tabName; // should be the tab name
void (*handler)(void); /// should be the function
};
//In Cpp
PanelTab RightFrameImGuiUI::tabNames[] = {{"Inspector",RightFrameImGuiUI::ShowSettingsPanel},
{"ViewSettings", RightFrameImGuiUI::ShowSettingsPanel}};
void RightFrameImGuiUI::MainRandomFunction
{
void (*DoPanel)() = tabNames[0].handler;
}
This is the full source. What I'm trying to do is be able to initialize a static structure array with panel names, and matching function that can be called. In MainRandomFunction for example or ShowRightFrame at the end is how I'm attempting to assign it but I'm getting.
error: request for member ‘handler’ in ‘tabNames[0]’, which is of non-class type ‘const char*’
warning: ‘typedef’ was ignored in this declaration [enabled by default]|
warning: ‘typedef’ was ignored in this declaration [enabled by default]|
error: request for member ‘handler’ in ‘tabNames[0]’, which is of non-class type ‘constchar*’|
That seems like a very misleading error message, which makes me think perhaps something else is going on there, but your initialization of DoPanel isn't correct.
Should be: void(*DoPanel)() = tabNames[0].handler;