Errors, bugs, questions - page 1416

 
When does "Internal compiler error" occur?  
Ilyas:
We know of two cases so far:
1) In bool &= operation (bool expression)
2) Unnecessary comma in initializing sequences: val={ {...},{...}, }.

Are these bugs still not fixed in the new build? My compiler still generates an error, I have to stick to 1159 build.

 
Renat Fatkhullin:
The requirement for templates is to place all methods inside the class description without putting bodies outside.

I see, the main thing is to keep this requirement, because just created stack and queue containers and a month later class templates appeared, and everything should work better with them :)

Another question is about class templates. There are two template classes, one class uses another, will a type transfer from one template class to another or not?

 
coderex:

I see, the main thing is to keep this requirement, because just created stack and queue containers and a month later class templates appeared, and everything should work better with them :)

Another question is about class templates. There are two template classes, one of the classes uses another one, will there be a type transfer from one template class to another or not?

Try it.
 
Renat Fatkhullin:
Try it.
I try it and get a few errors, think of another way to do it...
 

Ilyas:
На сегодня известно о двух случаях:
1) в операции bool &= (bool expression)
2) Лишняя запятая в инициализирующих последовательностях: val={ {...},{...}, }

Alexey Navoykov:
Have these bugs still not fixed in the new build? My compiler is still giving me an error, I have to stay on 1159 build.

Checked it just in case with extra comma in p.2 in MT4 890 - just gives error message.
 

Has anyone done a CList sorting?

Basically we need to override Compare.

But all the time I call Compare of the base class. But it doesn't work, I wonder what's wrong here...

Made a simple example:

class COperation : public CObject
  {
public:
   double           number;
   COperation(double p) { number = p;}

virtual int Compare(const CObject *node,const int mode=0);
  };
  
 int COperation::Compare(const CObject *node,const int mode=0)
  {
   const COperation *ppp = node;
   
   if(this.number > ppp.number)
     {
      return 1;
     }
   if(this.number < ppp.number)
     {
       return -1;
     }
   
  return 0;
 }   


void OnStart()
  {
   CList *list = new CList();
   list.Add(new COperation(3));
   list.Add(new COperation(4));
   list.Add(new COperation(7));
   list.Add(new COperation(2));
   list.Add(new COperation(3));
   list.Add(new COperation(9));
   list.Add(new COperation(0));
   list.Add(new COperation(1));
   
   Print("After Sort");
   COperation *node = list.GetFirstNode();
   string numbers = "";
   for(;node != NULL; node = node.Next())
     {
      numbers += (string)node.number + " ";
     }
    Print(numbers); 
    numbers = "";
     
   list.Sort(0);
   
   Print("Before Sort");
   node = list.GetFirstNode();
   for(;node != NULL; node = node.Next())
     {
      numbers += (string)node.number + " ";
     }
   Print(numbers); 
   
   
   delete list;
  }
Files:
sort.mq5  3 kb
 

When processing nested templates (MQL4), I see glitches with type passing - has anyone noticed that?

In particular, there's a class A with a template method, inside of which an object of another class B is created by a template constructor using the same type T that the method was initialized with. As a result, inside that method the typename correctly defines the type passed in, e.g. as int, but inside the B constructor the typename is already string.

SD?

 
The most orthodox way to sort the sheet is to overload it into an array, sort the array and overload it back.
 

I use sorting all the time - no problems at all.

You,sigma7i, have incorrectly overridden method Coperation::Compare(), it returns the wrong type of value, which the base method CObject::Compare() returns, and compiler takes it as separate, not virtual. As the result, only the base method is called in your objects, the compiler believes that there is no descendant...

 
sigma7i:

But all the time it calls Compare of the base class. But it doesn't work, so I think there's something wrong...

virtual int Compare(const CObject *node,const int mode=0) const;
Reason: