Pointer to this function type is not supported yet

 

Hello,

I'm trying to use function pointer in my object, but i got "Pointer to this function type is not supported yet" error at compile.

class OrdersManager 
{

    typedef void (*OrderCallback) (int);

    public:
    OrdersManager() 
    {
            
    }

    public:
    void displayOrderTicket(int _orderTicket)
    {
        Print(_orderTicket);
    }

    public:
    void displayOrderTickets()
    {
        // None of those lines are compiling.
        // All lead to "Pointer to this function type is not supported yet" compile error.
        OrderCallback ocb = displayOrderTicket;                     
        OrderCallback ocb = this::displayOrderTicket;
        OrderCallback ocb = this.displayOrderTicket;
        OrderCallback ocb = OrdersManager.displayOrderTicket;
        OrderCallback ocb = OrdersManager::displayOrderTicket;

        loopOpenOrders(ocb);
    }

    public:
    void loopOpenOrders(OrderCallback _orderCallback) 
    {
        for (int i = 0; i < OrdersTotal(); i++)
        {          
            if (OrderSelect(i, SELECT_BY_POS))
            {
                _orderCallback(OrderTicket());
            }
        }
    }

}

Examples i have found in MQL4 documentation are not using pure object-oriented-programming and show how to do it in global scope, which is indeed working, but i want to do it in class scope.

Anyone could help me achieving this ?


Thank you.

 
Function pointers work only with static class methods (or global functions).
 
lippmaje:
Function pointers work only with static class methods (or global functions).
Thanks for the clarification, any link from the docs about this ?
 
sed_lex:
Thanks for the clarification, any link from the docs about this ?

None that I know of. Try the Russian forum, maybe you'll get some more advice.

Use static functions and pass your instance via functor call, in case you need access to its properties. 

 _orderCallback(&this,OrderTicket());
 
sed_lex:
Thanks for the clarification, any link from the docs about this ?
What do you want more as documentation ? It doesn't work and this message "not supported yet" is there since something like 5 years (not sure exactly)...in summary since they introduced the feature in the language.
 
lippmaje:

None that I know of. Try the Russian forum, maybe you'll get some more advice.

Use static functions and pass your instance via functor call, in case you need access to its properties. 

Thanks, i'll do that.
 
sed_lex:

Hello,

I'm trying to use function pointer in my object, but i got "Pointer to this function type is not supported yet" error at compile.

Examples i have found in MQL4 documentation are not using pure object-oriented-programming and show how to do it in global scope, which is indeed working, but i want to do it in class scope.

Anyone could help me achieving this ?


Thank you.

I got the same error but it was because I was calling a variable when it is actually a function:

myTrade.ResultRetcode
And, as we know, functions must have parentheses. And voila, error solved
myTrade.ResultRetcode()