Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ScatterDraw & ScatterCtrl » Use function pointer
Use function pointer [message #48221] Tue, 06 June 2017 12:52 Go to previous message
deep is currently offline  deep
Messages: 263
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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: bug in scatterdraw.h and its fix
Next Topic: Dynamic example - 100% CPU core load
Goto Forum:
  


Current Time: Thu Apr 18 08:49:18 CEST 2024

Total time taken to generate the page: 0.02171 seconds