template<typename T> void F(T)
{
class A
{
void f() { new A; } // 'A' - declaration without typevoid g() { A* a; } // 'A' - pointer to this function type is not supported yet
};
};
voidOnStart()
{
F(0);
}
And there's also something wrong with the pointer conversion.
The following code does not compile:
class A
{
};
class B : protected A
{
};
voidOnStart()
{
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++.
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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Compilation error:
Here are a couple more mistakes:
And there's also something wrong with the pointer conversion.
The following code does not compile:
although the conversion is explicit here. Everything works in C++.
And there's also something messed up about bringing in the signposts.
It's right, the compiler is fighting.
Go read about dynamic_cast, static_cast and reinterpret_cast and when to use them correctly and when not.
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.