Pointer next to type or before the variable. Should that make a difference?

 

This works for all variables

   CArrayDouble   *_open =  openObj[TFIDX].At(0),
                  *_high =  highObj[TFIDX].At(0),
                  *_low  =  lowObj[TFIDX].At(0),
                  *_close=  closeObj[TFIDX].At(0),
                  *_atr  =  atrObj[TFIDX].At(0);

This only works for " _open " variable ( others don't seem to get the pointer )

   CArrayDouble*  _open =  openObj[TFIDX].At(0),
                  _high =  highObj[TFIDX].At(0),
                  _low  =  lowObj[TFIDX].At(0),
                  _close=  closeObj[TFIDX].At(0),
                  _atr  =  atrObj[TFIDX].At(0);
 
Any help?
 
There's no difference and that's why it only works for first one
 
Amir Yacoby #:
There's no difference and that's why it only works for first one

Lol this increased my confusion ( maybe I am missing something ). If there is no difference, shouldn't the second one work too?

 
Navdeep Singh #: Lol this increased my confusion ( maybe I am missing something ). If there is no difference, shouldn't the second one work too?

Only the first one is correct! The asterisk "*" (pointer declaration) has to be used with the variable name and not with the data-type (inherited from "C" convention).

 

FYI: It is missing in the MQL5 documentaion, but it's called a Dereference operator (*) .

Here is a reference from the C++ documentation — https://cplusplus.com/doc/tutorial/pointers/

 
Fernando Carreiro #:

FYI: It is missing in the MQL5 documentaion, but it's called a Dereference operator (*) .

Here is a reference from the C++ documentation — https://cplusplus.com/doc/tutorial/pointers/

Thanks for the help.

 
Navdeep Singh #: Thanks for the help.
You are welcome!
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
Reason: