I am trying to make a pointer to a method. When I try to compile it says "Pointer to this function type is not supported yet". I don't understand what the function type in this error means. Is it the return type? The method I am calling is a static function but is in a virtual child class. (the class is a filter for the built in expert signal) Would that be the reason I get the error? My code is just a copy of the comment from this post https://www.mql5.com/en/forum/172507#comment_4185703.
To declare a pointer to a function, specify the "pointer to a function" type, for example:
Now, TFunc is a type, and it is possible to declare the variable pointer to the function:
The func_ptr variable may store the function address to declare it later:
Pointers to functions can be stored and passed as parameters. You cannot get a pointer to a non-static class method.
Function pointers cannot point to member functions of any object. You may only use "simple functions" for function pointers.
Thank you.
I am trying to make a pointer to a method. When I try to compile it says "Pointer to this function type is not supported yet". I don't understand what the function type in this error means. Is it the return type? The method I am calling is a static function but is in a virtual child class. (the class is a filter for the built in expert signal) Would that be the reason I get the error? My code is just a copy of the comment from this post https://www.mql5.com/en/forum/172507#comment_4185703.
To declare a pointer to a function, specify the "pointer to a function" type, for example:
Now, TFunc is a type, and it is possible to declare the variable pointer to the function:
The func_ptr variable may store the function address to declare it later:
Pointers to functions can be stored and passed as parameters. You cannot get a pointer to a non-static class method.
If you really want to call a method of an object from a pointer, you can use a wrapper function with your normal parameters plus a pointer parameter to the object. Inside the wrapper you then use this to call the object method.
"Should be" ?
Sorry to do things you think should not be done
My use case with pseudo code :
class CGeneric { Environment envX; //--- need to call ProcessingGenericFunction(with correct params) : NOT POSSIBLE Call Wrapper(envX.instance,params); }; //--- function Wrapper(void*ptr,Params params) { ptr.ProcessingGenericFunction(params); } //--- class CBaseGenericContainer { Environment env; AnyType anyVariables; CGeneric embeddedInstances[];//using env void ProcessingGenericFunction(Params) { //--- Use AnyVariables and embeddedInstances } }; //--- class CSpecificContainer1 : CBaseGenericContainer { //--- define the specific action 1 env = Environment(1); }; //--- class CSpecificContainer2 : CBaseGenericContainer { //--- define the specific action 2 env = Environment(2); };
This come from practice, not theory. It COULD be done otherwise without any doubt, but it's what came from my dev process.
It's simplified pseudo version, the real code is using templates additionally.
"Should be" ?
Sorry to do things you think should not be done
My use case with pseudo code :
This come from practice, not theory. It COULD be done otherwise without any doubt, but it's what came from my dev process.
It's simplified pseudo version, the real code is using templates additionally.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to make a pointer to a method. When I try to compile it says "Pointer to this function type is not supported yet". I don't understand what the function type in this error means. Is it the return type? The method I am calling is a static function but is in a virtual child class. (the class is a filter for the built in expert signal) Would that be the reason I get the error? My code is just a copy of the comment from this post https://www.mql5.com/en/forum/172507#comment_4185703.
To declare a pointer to a function, specify the "pointer to a function" type, for example:
Now, TFunc is a type, and it is possible to declare the variable pointer to the function:
The func_ptr variable may store the function address to declare it later:
Pointers to functions can be stored and passed as parameters. You cannot get a pointer to a non-static class method.