Errors, bugs, questions - page 1615

 
Hi all. Is there any way to re-login an account when the MT5 server connection is interrupted?
 

Compilation error:

class A
{ 
};

template<typename T>  void func(T *const &a[])  { } 


void OnStart()
  {
    A *const a[] = { NULL };
    func(a);      //  'a' - cannot convert from const pointer to nonconst pointer
  }
 

Here are a couple more mistakes:

template<typename T> void F(T)
{
  class A
  {
    void f()  { new A; }  // 'A' - declaration without type
        
    void g()  { A* a; }   // 'A' - pointer to this function type is not supported yet
  };
};


void OnStart()
  {
    F(0);
  }
 

And there's also something wrong with the pointer conversion.

The following code does not compile:

class A
{
};

class B : protected A
{
};

void OnStart()
  {
    A* a;
    B* b= (B*)a;  // conversion from 'B *' to 'A *' is not accessible because of inheritance access
  }

although the conversion is explicit here. Everything works in C++.

 
Alexey Navoykov:

And there's also something messed up about bringing in the signposts.

That's right, the compiler swears.
 
Комбинатор:
It's right, the compiler is fighting.
What's right? Open C++ and check how it should be.
 
Alexey Navoykov:
Go and read about dynamic_cast, static_cast and reinterpret_cast and when to use them correctly and when not.
 
Комбинатор:
Go read about dynamic_cast, static_cast and reinterpret_cast and when to use them correctly and when not.
Let's avoid unnecessary flooding and philosophy, OK? We're talking about a specific construct that should compile.
 
Alexey Navoykov:

C++ converts this code to reinterpret_cast and MQL to dynamic_cast. And as far as I understand, this is exactly the case when compiler can find dynamiccast error during compilation.

reinterpret_cast is illegitimate in this case, so the fact that this code compiles in C++ is not an argument.

 
Комбинатор:

C++ converts this code to reinterpret_cast and MQL to dynamic_cast. And as far as I understand, this is exactly the case when the compiler can find a dynamiccast error during compilation.

Reinterpret_cast is illegitimate in this case, so the fact that this code compiles in C++ is not an argument.

Wait, why do you mix things up? What does dynamic cast have to do with it? The compiler's tasks do not include playing Sherlock Holmes and looking for something in the program logic. It only performs a formal check of compliance with the language standard, nothing more. And everything is correct from the viewpoint of the standard.

If you had looked carefully at my sample, you would have seen that the problem was related to protected. If you change it to public, everything is ok. The object itself is not changed because of this. That is, the MQL compiler just has an unnecessary restriction, that's all.

So don't speculate and look for a secret meaning where there is none, which is just a trivial compiler error.

Reason: