Errors, bugs, questions - page 1297

 
_Konstantin_:

I'm trying to override it, but I get a call non-const method for constant object error, because non-const methods cannot be used in a constant method. I can't figure out how to properly override the virtual constant method myself.

The way out is not to use non-const methods in const methods. And you cannot override this in any way.
 
A100:
The solution is not to use non-const methods in const methods. And there is no way to jump over it.

Well, that's the thing, MQ hasn't wanted to change the Compare virtual method for several years, which is intended to be used in the created sorting mechanism, and without its redefinition this mechanism simply doesn't work. As a result, we have to create our own sorting mechanism without using the MQ's intended sorting mechanism.

I created my own sorting mechanism from the very beginning of introduction of OOP in MQL4, and naively thought that this point was fixed in MQL5, but I was wrong :)

 
_Konstantin_:

Well, that's the thing, MQ doesn't want to change the Compare virtual method for several years, which is intended to be used in the created sorting mechanism, and without its redefinition this mechanism simply doesn't work. As a result, we have to create our own sorting mechanism without using the MQ's intended sorting mechanism.

I created my own sorting mechanism from the very beginning of introduction of OOP in MQL4, and naively thought that this point had been already fixed in MQL5, but I was wrong :)

Don't you allow to use the const modifier?

class IntObject : public CObject
{
public:
   int Value;
   virtual int Compare(const CObject *node,const int mode=0) const
   {
      const IntObject* intObj = node;
      if(intObj.Value < Value)return MORE;
      else if(intObj.Value > Value)return LESS;
      return EQUAL;
   }
   IntObject();
   IntObject(int value){Value=value;}
};
 
C-4:

Doesn't your religion allow you to use the const modifier?

It has a different type of error (call non-const method for constant object)

#define  NO_CONST
class IntObject : public CObject {
public:
   virtual int f(const CObject *node ) NO_CONST { return 0; }
   virtual int Compare(const CObject *node,const int mode=0) const { return f( node ); }
};
It cannot be overcome for fundamental reasons
 
A100:

It has a different type of error (call non-const method for constant object)

It cannot be overcome for fundamental reasons.
How could it not be? It's enough to make the method to be called in the constant object constant.
 
C-4:
How could it not be? It is sufficient to make the method being called in the constant object a constant.
f() can only be made const if it allows it
class IntObject : public CObject { public:
        int i;
   virtual int f(const CObject *node ) const { return i = 0; } //ошибка
};
 

I have a question, maybe somebody will tell me something!

I create an offline synthetic chart 1/EURUSD,GBPUSD and also set EURUSD-1 GBPUSD+1 in Equity

I get identical charts and indicator lines, almost no difference https://charts.mql5.com/7/422/synthetic-m15-alpari-limited-6.png

And I create a second offline synthetic chart EURUSD,1/GBPUSD and set EURUSD+1 GBPUSD+1 in the equity

I get NOT identical lines of the chart and indicator https://charts.mql5.com/7/422/synthetic-m15-alpari-limited-5.png

The most probable reason is that EUR-USD is near to parity that is why its reversal with 1/1.08 gives minimum distortion and GBPUSD is further from parity that is why 1/1.48 gives more distortion.

Can you tell me the correct way to reverse an instrument?

 

Earlier it was OK, but now I cannot set a line of 28 instruments in the Symbol_Side_A parameter in the Equity indicator (attached):

EURGBP-0.1 EURUSD-0.1 GBPUSD-0.1 EURCHF-0.1 EURCAD-0.1 EURAUD-0.1 EURNZD-0.1 EURJPY-0.1 AUDUSD-0.1 NZDUSD-0.1 USDCAD-0.1 USDCHF-0.1 USDJPY-0.1 GBPAUD-0.1 GBPCAD-0.1 GBPJPY-0.1 GBPCHF-0.1 NZDJPY-0.1 AUDJPY-0.1 CADJPY-0.1 CHFJPY-0.1 AUDCAD-0.1 NZDCAD-0.1 AUDCHF-0.1 AUDNZD-0.1 CADCHF-0.1 NZDCHF-0.1 GBPNZD-0.1

Part of the data is cut off for some reason and is not displayed in this row. It only appears when I activate the Symbol_Side_A line. What can be the problem? Please advise.

My MT4-765 terminal. ALPARI and RVD have the problem, while GKFX is OK! Strange!

 

Is it really so hard to make the forum so that the names of uploaded files don't change? Like on normal forums!

I downloaded the EquityHedgeGraph2(v670) indicator above. So why did the name get messed up?

 
You cannot comment inside the parameter list #define
#define  MACRO( X/*комментарий*/ )       (X) //ошибка компиляции
but it may be necessary, especially if there are several parameters