Download MetaTrader 5

Returning reference to a member variable

To add comments, please log in or register
Tom Test
19
Tom Test  

Dear MQL4 Users,

is it possible to return a reference in MQL4? E.g. to a member variable. In C++ this is common practice, but I get an ugly "reference cannot used" error from the mql4 compiler.

Thanks in advance,
Tom

Carl Schreiber
7354
Carl Schreiber  

You can 'hand over' a variable by reference:

void func( double &var ){..}

But I think you know it.

whroeder1
16076
whroeder1  
tomtester: is it possible to return a reference in MQL4?
  1. Return Operator - MQL4 Documentation What can be returned: simple types, simple structures, object pointers.
  2. //+------------------------------------------------------------------+
    //| Mql4 is like C++ except: no typedefs or namespaces, no pointers  |
    //| to POD, no operator(), operator*, or operator->, no implicit     |
    //| conversions (operator bool), no templated classes, no Koenig     |
    //| lookup, can't return references, no dynamic cast, no exceptions, |
    //| no class friends, no multiple inheritance. Can't use template    |
    //| <class X...> must be template <typename x...>. f(const T&){}     |
    //| f(123) or f( f2() ) doesn't compile (Build 765.) Must have a     |
    //| actual variable. Structures must be passed by reference.         |
    //+------------------------------------------------------------------+
    




To add comments, please log in or register