Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 936

 
Igor Makanu:

again: just because you didn't get a compile error doesn't mean your template class was included - where is the CData class object ? - I see a template declaration, but where is such a variable? - object ?

if you "vitally need" to solve the question, then make fully reproducible code - completely it's without ..... comments at your discretion and again, I don't understand the logic of using macro substitution

maybe that's the point, I rarely use macros, at least if I use a macro I understand what it eventually results in, in your example it's a mystery to me

Yes you are right the object was not created so I checked

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#define  templ(T)          template<typename T>// задача данного макроса определять int bool double и т.д


#define  Vosmas(a,b,c,d,e) /*return*/(Fun(a,b,c,d,e))//a- массив, 
                                                    //b- номер строки если нужен
                                                    //c,d- номера измерений если нужны и массив многомерный

int Mas[2],Mas2[2][2],Mas3[2][2][2];

int OnInit()
{int Perem=0;
 Perem=Vosmas(Mas,0,0,0,3);
 Print("Vosmas: ",Perem);//результат 3
return(INIT_SUCCEEDED);}

class CData{
public:CData(){};~CData(){};

       int Total(int &mas[]    ,int y1=0){return(mas[y1]);}  
       int Total(int &mas[][]  ,int y1=0/*,int y=0*/){return(mas[y1][0]);}
       int Total(int &mas[][][],int y1=0/*,int y=0,int u=0*/){return(mas[y1][0][0]);}};
       
         
templ(T) T Fun(T &a[],int b,int c,int d,int e){a[b]=e; return (a[b]);}

I don't see why I need such a programming language and why would I need such classes if I can't even overload them, everything is dead and static.

 
How do I write a letter to the mql4 developers how to see the compiler code, can I add more features to it so it's not so static?
 
Seric29:

Yes you're right the object was not created that's how I checked

As a result, overloading is not possible, which is a minus, so why would I need such a programming language and why would I need such classes if I can't even overload everything is dead and static?

Really?

You didn't know that.

How do people write complicated things then? It's beyond comprehension...

 
Seric29:

The task of the macro is to call the function from the class and pass the value to this function, and since the macro can take an array of any dimension, I'm trying to make such a scheme. Of course a lot of stones, but I need to call the function from the class and I do not know how to call a simple function from the class (in my case, the method Total has no description) is not written in Help, there are complex examples related to the transfer.

Here is an example a macro takes an array of any dimension, it is bad that developers have cut these features normal work with complex elements

You can do it without a template, but it's better with a template.

I didn't want to, but I opened the terminal, here's your example:

#property strict
#property  show_inputs
//+------------------------------------------------------------------+
//#define templ(T)          template<typename T>// задача данного макроса определять int bool double и т.д

#define  Vosmas(a,b,c,d,e)  5
int Mas[2],Mas2[2][2],Mas3[2][2][2];//объявил массивы которые будут хранить информацию// обработка с помощью классов должна быть любого типа templ(T)
//+------------------------------------------------------------------+
void OnStart()
  {
   int Perem=0;
   Perem=Vosmas(Mas,0,0,0,0);
   Print("Vosmas: ",Perem);
   Perem=Vosmas(Mas2,0,0,0,0);
   Print("Vosmas: ",Perem);
   Perem=Vosmas(Mas3,0,0,0,0);
   Print("Vosmas: ",Perem);//во всех случаях результат 5
  }
//+------------------------------------------------------------------+

I commented out the macro substitution, the code compiles, so it doesn't work? I asked three times why a template that isn't used and why a macro substitution that just duplicates a language keyword

Not only do I not understand what's needed, but I don't understand what to do with code that won't compile part of it.

HH: If you are trying to make a multidimensional array using this template or a macro - imho, will not work, find a ready-made solution by searching through the forum and use

ZS: I definitely give up, it's not a question for me.

 
Seric29:
How do I write a letter to the mql4 developers how to see the compiler code, can I add more features to it so it's not so static?

Not in case of putting trousers over your head :)

 
Artyom Trishkin:

Really?

You didn't know that.

How do people write complex things then? It is beyond comprehension...

Well, how complicated can you write here if memory access is denied to work with dynamic functions, even overloading is not possible, so you have to write an extra 1000 lines of code to complete your program, initiate extra loops and variables, hence the performance of the program is 0.

 
Seric29:

Well, what's so hard to write if memory access is denied, you can't work with dynamic functions, even overloading is impossible, so you have to write an extra 1000 lines of code to finish your program, initiate extra loops and variables, hence the program's performance is 0.

Well, if the program structure is initially dead, yes, there is no way.

The program is written at the very end. First, a thoughtful approach to program structure.

I honestly don't understand why you've been fighting for months with something that is done differently, and in five minutes. I really don't understand...

 
Igor Makanu:

i didn't want to, but i opened my terminal, here's your example:

I commented out the macro substitution, the code compiles, so it doesn't work? I asked three times why a pattern that isn't used and why a macro substitution that just duplicates a language keyword

Not only do I not understand what's needed, but I don't understand what to do with code that won't compile part of it.

HH: If you are trying to make a multidimensional array using this template or a macro - imho, will not work, find a ready-made solution by searching through the forum and use

ZS: I definitely give up, it's not a question for me.

Here I gave an example thatVosmas macro accepts any arrays. The only solution for arrays is to use arrays of the same dimension, I'm not talking about all sorts of pointers and references and dynamic functions that work in c++, and it's also a problem to output a function in c++, specify type and other stuff, too static language and all, you can't write the really cool stuff here.

 
Seric29:

Here I gave an example thatVosmas macro accepts any arrays. The only solution for arrays is to use arrays of the same dimension, I'm not talking about all sorts of pointers and references and dynamic functions that work in C++, and also the problem of deriving a function in C++ specify type and other nonsense in short too static language and all, you cannot write really cool things here.

Start reading C++ basics, MQL has minimum differences!

ZS: congratulations, you have written a universal macro that can do everything, arrays are the easiest thing it can "handle", example to reproduce:

#property strict
#define  Vosmas(a,b,c,d,e)  5
int Mas[2],Mas2[2][2],Mas3[2][2][2];//объявил массивы которые будут хранить информацию// обработка с помощью классов должна быть любого типа templ(T)
//+------------------------------------------------------------------+
void OnStart()
  {
   int Perem=0;
   Perem=Vosmas(Mas,0,0,0,0);
   Print("Vosmas: ",Perem);
   Perem=Vosmas(Mas2,0,0,0,0);
   Print("Vosmas: ",Perem);
   Perem=Vosmas(Mas3,0,0,0,0);
   Print("Vosmas: ",Perem);//во всех случаях результат 5
   
   class CA{public: int a;} A;
   class CB{public: int b;} B;
   class CC{public: int c;} C;
   class CD{public: int d;} D;
   class CE{public: int e;} E;
   Perem=Vosmas(A,B,C,D,E);     Print("Vosmas: ",Perem);//во всех случаях результат 5
   Perem=Vosmas("УРА","Я","УЧУ","MQL","4");     Print("Vosmas: ",Perem);//во всех случаях результат 5
  }
//+------------------------------------------------------------------+
 
Igor Makanu:

start reading C++ basics, MQL has minimal differences!

ZS: congratulations, you've written a universal macro that can do everything, arrays are the easiest thing it can "handle", example to follow:

Well, I wanted to get a grip on this by passing an array into a macro and in the macro call an overloadable function and return the result, seems like a primitive task but when you call an overloadable function in a macro it throws a warning that functions 3 turns out that in the macro you need to write a criterion that will determine which of the overloadable functions to call and here again you have to ask how to do this check, in general the idea fails.