How to define a refrence variable ?

 

Hi I have a question may be so simple but i have problem :

I want to access some variable by refrence . 

suppose we have a class :

class CLayer{
...
}
and a class 
class CNetwork{
private:
CLayer *m_layers[];
public:
....
void getout(double val);
}
void CNetwork::getout(double val)
{
....
unsigned layers=ArraySize(m_layers);
CLayer &layer=m_layers[layers-1];
....
}

 but for the last line of code i get this errors :

'&' - reference cannot used     Network.mqh     105     17
'=' - object required           Network.mqh     105     30

 whats my mistake ?

 
pumper:

Hi I have a question may be so simple but i have problem :

I want to access some variable by reference . 

suppose we have a class :

 but for the last line of code i get this errors :

 what's my mistake ?

Where in the documentation did you see you can define a reference variable ? You can't.

Please read mql5 documentation, and don't try to use other language statement with mql5 compiler.

 
angevoyageur:

Where in the documentation did you see you can define a reference variable ? You can't.

Please read mql5 documentation, and don't try to use other language statement with mql5 compiler.

in docs only mentioned about passing by refrence to function.but nowhere found anything else.not mentioned about it.is this means we can't use it every where else ?
 
pumper:
in docs only mentioned about passing by refrence to function.but nowhere found anything else.not mentioned about it.is this means we can't use it every where else ?
Exactly. You can't.
 
angevoyageur:
Exactly. You can't.

Is it legal to use pointers in such a case ?

i mean :

CLayer *layer=m_layers[layers-1];

 returns no error and is a pointer to that element.

 
pumper:

Is it legal to use pointers in such a case ?

i mean :

 returns no error and is a pointer to that element.

Of course.
Reason: