В этой статье автор рассматривает различные способы реализации свойств в стиле Visual Basic на C++. Некоторые способы специфичны для Visual C++, тогда как другие годятся для применения в любой программе, написанной на языке C++.
Alexey Volchanskiy: Alexey, I'm all for it, but we should do a vote, not here. There are some crutches here, I haven't tried it in MQL http://rsdn.ru/article/vcpp/props.xml
There's something wrong with the encoding on your link. I'm getting a lot of red text. But I know what you mean, I've read about these crutches before. It's not possible to implement it in MQL at the moment, because ghost operator overloading is not supported.But this native feature in VS is very useful, especially when wrapped in a macro. And it doesn't consume any additional resources. So, it's high time we implement properties in MQL too, because everything looks clumsy without them.
I figured it out, found a bug in MQL4 compiler. I was inattentive and it took me 2 days to find it. The essence of the problem is this: I will give you the simplest code. I don't get a compilation or warping error, I get a runtime error.
double ptest = double(test); // тут должна быть ошибка компиляции!!!
There is no need for any mistake here. There is a clear type conversion here. It would be like this in VS
Please remind me how to sort the symbols in the market overview window (MT4, MT5). On one terminal they are nicely sorted, on the other one they are a mess. I sorted it a long time ago - I don't remember how I did it. There is nothing in documentation about it, except for dragging symbols one by one to a new place. But I have not done it exactly - it is possible to sort the whole list manually. :-/
Vasiliy Sokolov: You cannot cast a class to a meaningful type, even explicitly. It is definitely an error.
It's not a class, it's a pointer, and a pointer is a number.
class A{};
void f()
{
A *a;
int i = int(a);
}
C++ compiles without errors
If you disallow a direct explicit conversion to double, the next time it will have int instead of double with the same result and the compiler will be guilty again. You have to distinguish your own errors from the compiler's errors.
It's not a class, it's a pointer, and a pointer is a number - learn the math.
C++ compiles without errors
If you disable direct explicit conversion to double, the next time it will have int instead of double with the same result and the compiler will be guilty again. You should distinguish your own errors from the compiler's errors.
There is no pointer there, because pointers do not exist in MQL4/5. There are handles.
----------------------
I've received an answer from Service Desk
Support Team2015.08.24 09:44
Thanks for the post, will fix it. Indeed, there must be a compilation error here.
Support Team2015.08.24 14:39
Status: OpenClosed
Thanks for the post, fixed. The compiler will now give a compilation error.
There is no pointer there, because there are no pointers in MQL4/5. There are descriptors.
A descriptor is still a specific number. The fact that this number does not point to a specific memory location does not deprive it of the properties of a number.
Of course, in terms of "how it's stored in memory", you're right. But it makes no sense to convert a descriptor to a number or vice versa, and it's most likely a bug in the code. In the near future, if an appropriate conversion statement is overloaded in the class, it will be called.
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.
Gentlemen, how would you like to significantly improve the usability of the language by addingproperty: https://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx
The constant dancing with setters, getters and brackets is very annoying.
Gentlemen, how would you like to significantly improve the usability of the language by addingproperty: https://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx
The constant dancing with setters, getters and brackets is very annoying.
Alexey, I'm all for it, but we should do a vote, not here. There are some crutches here, I haven't tried it in MQL http://rsdn.ru/article/vcpp/props.xml
There's something wrong with the encoding on your link. I'm getting a lot of red text. But I know what you mean, I've read about these crutches before. It's not possible to implement it in MQL at the moment, because ghost operator overloading is not supported.But this native feature in VS is very useful, especially when wrapped in a macro. And it doesn't consume any additional resources. So, it's high time we implement properties in MQL too, because everything looks clumsy without them.
I figured it out, found a bug in MQL4 compiler. I was inattentive and it took me 2 days to find it. The essence of the problem is this: I will give you the simplest code. I don't get a compilation or warping error, I get a runtime error.
There is no need for any mistake here. There is a clear type conversion here. It would be like this in VS
What difference would it make?There is no need for any mistake here. There is an explicit type conversion here.
You cannot cast a class to a meaningful type, even explicitly. It is definitely an error.
It's not a class, it's a pointer, and a pointer is a number.
C++ compiles without errors
If you disallow a direct explicit conversion to double, the next time it will have int instead of double with the same result and the compiler will be guilty again. You have to distinguish your own errors from the compiler's errors.
It's not a class, it's a pointer, and a pointer is a number - learn the math.
C++ compiles without errors
If you disable direct explicit conversion to double, the next time it will have int instead of double with the same result and the compiler will be guilty again. You should distinguish your own errors from the compiler's errors.
There is no pointer there, because pointers do not exist in MQL4/5. There are handles.
----------------------
I've received an answer from Service Desk
Indeed, there must be a compilation error here.
Support Team 2015.08.24 14:39
There is no pointer there, because there are no pointers in MQL4/5. There are descriptors.
A descriptor is still a specific number
But it makes no sense to convert a descriptor to a number or vice versa, and it's most likely a bug in the code.
In the near future, if an appropriate conversion statement is overloaded in the class, it will be called.