It also seems the same with structs and '&'
-
Not redundant. You have to declare the variable as a pointer. It is the use of that pointer that does not require an asterisk (unlike C/C++).
-
Your posted code isn't using pointers.
What can be returned: simple types, simple structures, object pointers. With the return operator you can't return any arrays, class objects, variables of compound structure type.
Unfortunately the documentation is outdated in a lot of places.
And there are even places where there are documentation for stuff which are not yet implemented.
Unfortunately the documentation is outdated in a lot of places.
And there are even places where there are documentation for stuff which are not yet implemented.
Yes it seems a preperation for something.
I asked Metaquotes to fix this documentation (link from William). I don't know since when it's possible, but it's certainly not a recent change.
Though I never use it as it implies a copy, which is not efficient at all. What could be a good usage ?
I asked Metaquotes to fix this documentation (link from William). I don't know since when it's possible, but it's certainly not a recent change.
Though I never use it as it implies a copy, which is not efficient at all. What could be a good usage ?
Well, yes you seem to be right. It is returning the object by value, which is copying it using the copy constructor.
I didn't know that you can return an object by value like that, I am almost sure it wouldn't compile in previous (maybe not recent) versions.
class MyClsA { private: int m_size; public: MyClsA(const MyClsA &other) // copy constructor { this.m_size=other.m_size; } MyClsA Max(const MyClsA &a,const MyClsA &b) { if(a.m_size>b.m_size) return a; //--- calls copy constructor else return b; // calls copy constructor } };
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When did the '*' that marks that a method returns an object pointer became redundant in MQL5?
It also seems the same with structs and '&'