Home » U++ Library support » ScatterDraw & ScatterCtrl » Use function pointer
Use function pointer [message #48221] |
Tue, 06 June 2017 12:52  |
 |
deep
Messages: 266 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi,
Actually this is not Scatter package issue.
I want to use Function pointer (Class pointer) to access internal variables from ScatterCtrlDemo.
From file tab14_userequations.cpp
ScatterDemo *ConstructUserEquation()
{
static TabUserEquation tab_ue;
return &tab_ue;
}
INITBLOCK {
RegisterExample("User equation", ConstructUserEquation, __FILE__);
}
From file main.cpp
struct Example {
ScatterDemo* (*ctrl)();
String name;
int index;
};
Array<Example>& Examples()
{
static Array<Example> x;
return x;
}
void RegisterExample(const char *name, ScatterDemo* (*ctrl)(), String fileName)
{
Example& x = Examples().Add();
x.name = name;
x.ctrl = ctrl;
x.index = ScanInt(GetFileName(fileName).Mid(3, 2));
}
Now with RegisterExample static TabUserEquation tab_ue gets added to Examples Array as Type ScatterDemo.
I want to use tab_ue in other part of code.
How to declare it so that it will be part of Examples Array and available independently.
Warm Regards
Deepak
[Updated on: Tue, 06 June 2017 12:53] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:25:01 CEST 2025
Total time taken to generate the page: 0.00995 seconds
|