
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I too am a little confused because I seldom use the "assignment operator" methods myself, and even less the "copy constructor". So, my explanation was probably flawed. That is why I linked the C++ explanation to make it a bit more clear for you (and for me).
From your code, I can see that you implemented the "copy constructor" (and not the "assignment operator" as I originally suggested), and that seems to be the correct way as per the warning given by the compiler. I also learned something new with this, so you have my thanks.
@Vladislav Boyko well thats interesting since it already worked as intended before build 5200, and it still works on 5200, it just gives the warning on compile that it's deprecated and will be removed
MetaQuotes is currently improving the compiler and I am not sure how exactly MQL5 will change in the next release build. It is best to wait for the next release and read about the MQL5 changes in the release notes.
If you get a warning for only one structure (not several) and if that structure is not very large, then you can post the declaration of that structure and I will try to help you add an explicit "operator=" or an explicit copy constructor
If you get a warning for only one structure (not several) and if that structure is not very large, then you can post the declaration of that structure and I will try to help you add an explicit "operator=" or an explicit copy constructor
But it's likely that starting with the next release build, the compiler will automatically add both an implicit copy constructor and an implicit 'operator='. If so, that would make their explicit versions optional in most cases.
I think the following proves that in build 5222 the compiler generates an implicit copy constructor:
Below is a quote from the documentation, which demonstrates the explicit and implicit way of calling the copy constructor (do not confuse explicit/implicit call with explicit/implicit constructor)
https://www.mql5.com/en/docs/basis/types/classes#constructor
I think the following proves that in build 5222 the compiler generates an implicit copy constructor:
Below is a quote from the documentation, which demonstrates the explicit and implicit way of calling the copy constructor (do not confuse explicit/implicit call with explicit/implicit constructor)
This is very interesting since if I try to run exactly your Class A code, I get the assignment operator being deprecated warning as well as a compilation error "attempting to reference deleted function 'void A::operator=(const A&)'" at line 20 with hints "function 'void A::operator=(const A&)' was explicitly deleted here" and "see declaration of function 'A::operator='". Maybe try running this code on a current release build terminal with 5200, the beta might be allowing things that are not defined and might even lead to some bugs and errors down the line.
the beta might be allowing things that are not defined and might even lead to some bugs and errors down the line.
The beta version contains new compiler improvements (not present in the 5200 release). But don't rush to update the terminal, as the beta version has a higher probability of bugs.
Maybe try running this code on a current release build terminal with 5200