Errors, bugs, questions - page 1736

 
coderex:

if anyone is interested, servicedesk's answer:

На данный момент оператор *(dereference/indirection) можно использовать только для указателей на объекты классов и это rvalue

I am very interested! Please explain the Service Desk answer with an example.

& == GetPointer(). * - nothing has changed.

 
fxsaber:

I am very interested! Please explain the Service Desk answer with an example.

& == GetPointer(). * - nothing has changed.

What example do you need?
 
coderex:

if anyone is interested, the answer is servicedesk:

На данный момент оператор *(dereference/indirection) можно использовать только для указателей на объекты классов и это rvalue
I sent them a suggestion the other day about introducing pointers to any data type. And this ridiculous restriction is annoying.
 
Alexey Navoykov:
By the way, I sent them a proposal the other day about introducing pointers to any data type. And this ridiculous restriction is already annoying.
It would be nice to introduce overloading of * operator, because without it we can't realize identity with STL, also it would be nice to introduce typedef in full, not only on calback`i
 
coderex:
it would be nice to introduce overloading of * operator, because without it we can't realize identity with STL, also it would be nice to introduce typedef in full, not only on calback`i
Yes, I agree. Everything is in some unfinished state. And in terms of overloads I'm more interested in the ghost operator, it's hard to do without it.
 
coderex:
What kind of example do you want?
What you want from * and &. Something simple but illustrative. So you can see the convenience.
 
fxsaber:
What you want from * and &. Something simple but illustrative. To see the convenience.

What I want I've already written above.

You may make up an example with the '&' operator yourself where you use GetPointer(...), it's essentially a short form

The example with the '*' operator - I don't know if it helps you understand:

class Iterator
  {
   int m_value;
public:
   Iterator(const int val) : m_value(val) { }
   int operator*() { return m_value; }
  };

int main(int argc, char **argv) {
   Iterator *_it = new Iterator(5);
  
   int _val = **_it;
//---
   return 0;
}


it works in C++, but in MQL you'll have to make a geter to get m_value.

 

Add to Help that ChartRedraw(MainChartID) is not suitable for redrawing OBJ_CHART. The ChartRedraw(ObjChartID) is required.

Therefore, the example in the Help is incorrect.

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_CHART
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_CHART
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_CHART - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

Please do not limit the scale to N <= 5 (size of area under bar = 2^N).

This is necessary (and has become expedient) to be able to look at the tick history in more detail.

 
Please clarify. Script
class A
{
public:
  const int a;
  
  A( int c = 0 ) : a(c) {}
  
  virtual int f()
  {
    Print(__FUNCTION__);
    
    return(this.a);
  }
};

class B : public A
{
public:
  const int b;
  
  B( int c = 0 ) : A(c), b(this.f()){}

  virtual int f()
  {
    Print(__FUNCTION__);
    
    return(this.a);
  }
};


void OnStart()
{
  B b;  
  A* a = new B;
  
  delete a;
}

Result

2016.10.18 09:35:01.981 Test14 (GBPUSD,M1)      B::f
2016.10.18 09:35:01.981 Test14 (GBPUSD,M1)      B::f

What is the reason for the output of B::F and not A::f? The script is written in such a way that f is called BEFORE the constructor body is executed (in bold). But at this point the A base class constructor has already been called. That's why this.f() seems to refer exactly to the base class before the B constructor is called. Please explain where the reasoning/prediction error lies.