Discussion of article "MQL5 Programming Basics: Lists" - page 7

 
Because of the necessity to use switch, the whole point is lost. If that's the case, you can do without unnecessary fiddling, just a different array for objects of each type. So, "the king is naked".
 

Sometimes it seems that many or some people here have confused fanaticism and reality, what is desirable and what is possible.

Instead of taking a shovel and digging, there is a sophisticated flaunting of the shovel theme: "and maybe here on the edge so sharpen it", "with maybe here a corner twist".... Everything ends at the level of the shovel.

 
Integer:
Because of the necessity to use switch, the whole point is lost. If that's the case, you can do without unnecessary fiddling, just a different array for objects of each type. So, "the king is naked".

This is a demonstration that a sheet can contain objects of any type. Plus each type can be dynamically identified if it includes additional information about its type. This "additional information" is a weak link, but unfortunately MQL doesn't provide tools for type control, so we can't do without it. If anyone knows a better solution: please submit the code, it will be interesting to see it.

As if your comment hints that you have not dealt with the pattern "template method")))

 
C-4:

1. This is a demonstration that a sheet can contain objects of any type.

2. Your comment hints that you haven't dealt with the "template method" pattern)))

1. That's nice, of course. But what's the use of it?

2. Yes. And...? Did I lose a lot? This is again a conversation about how to "sharpen" or "bend" something with a shovel.

 
What are the "patterns" we're talking about here? Is it someone who imposed his way of thinking and everyone dances? Why are these patterns elevated to such a high rank?
 
Integer:

1. That's nice, of course. But what good is it?

2. Yes. And...? Did I lose a lot? This is again a conversation not on the merits but on the subject of how to "sharpen" or "bend" something there at the shovel.

So what was the task? What was to be done? I thought it was asked to show the work of different classes with one node.
 

I have also managed to put different objects into one array, and note that it is more clear, because there is nothing extra:

class base{
   private:
   public:   
};

class cl1:public base{
   private:
      int m_v1;
      int m_v2;
   public:  
   void cl1(int v1,int v2){
      m_v1=v1;
      m_v2=v2;   
   }
   void f1(){
      Alert("(1) "+m_v1);
   }
   void f2(){
      Alert("(1) "+m_v2);   
   }
};

class cl2:public base{
   private:
      int m_v1;
      int m_v2;
   public:  
   void cl2(int v1,int v2){
      m_v1=v1;
      m_v2=v2;   
   }
   void f3(){
      Alert("(2) "+m_v1); 
   }
   void f4(){
      Alert("(2) "+m_v2); 
   }
};

base * a[];

int x1=1;
int x2=2;

int x()
  {
   
   return(x1=x2);
  }

void OnStart()
  {

   ArrayResize(a,10);
   
   cl1 * a1;
   
   a[0]=new cl1(1,2);
   a[1]=new cl2(3,4);  
   
}

So what? Nothing. Overloading does not work, you need to register the type, then through switch. That's all the joy.

 
Integer:
What are the "patterns" we're talking about here? Is it someone who imposed his way of thinking and everyone dances? Why are these patterns elevated to such a high rank?
No, it's nothing, don't worry... It's okay. It's just that one day a bunch of programmers generalised some universal algorithms and called them "patterns". Imagine, these idiots even published a book on them:))))))! People have nothing to do!
 
C-4:
What was the task? What was to be done? I thought you asked to show how different classes work with one node.
You did. It's cool, of course. But as it turns out, it's not all that's needed.
 
Integer:

I have also managed to put different objects into one array, and note that it is more clear, because there is nothing extra:

So what? Nothing. Overloading does not work, you need to register the type, then through switch. That's all the joy.

Nothing extra? Your classes are 100% redundant. All cl1 methods and data are almost completely duplicated by cl2 class, while base is empty.