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
That's what I was expecting the copy... The default copy constructor is not an error.
ButDmitry says a new object will be allocated in memory and a pointer ofPOINTER_AUTOMATIC type will be returned.
Everyone understands MQL quirks in his own way)
Yep. It turns out there is no Father Christmas.
I haven't written about any object in memory.
OK, there were disputes once about how to distinguish a reference from a pointer. But now it seems we cannot distinguish an object from a pointer.
Where does a copy of an object come from? A copy of a pointer, yes, but pointing to the same object.
We have an array of objects. An assignment operator is called on the first element of this array, which is passed the separately created object (although, the operator is undeclared). What do you think should be in the first element of the array after that? In my opinion, the object should remain.
My point is that an explicitly declared copy constructor would not change anything in this test.
How can you fail to see the obvious...
An object array item contains a pointer and an object in the pointer array item... is this really normal?
In the first case, an object pointer goes to the array in the second case, the copy constructor should work, how can these operations be equivalent?
Not the copy constructor, but the assignment operator, but that's the little things.
It's the object that should go into an element of an object array.
In the first case - you have exactly an object array, what kind of "pointers"?
We have an array of objects. The assignment operator is called at the first element of this array and the separately created object is passed to it. What do you think should be in the first item of this array after that? In my opinion, the object should remain.
А... It's not good there at all))) An array of automatic pointers, and in it they also cram an object created dynamically. Then there are 3 objects, two of them will be automatically deleted and one will leak. If it is compiled.
It should be like this:
A* m_A[2];
and so:
m_A[0] =GetPointer(a);
And at the end it goes like this:
А... It's not good there at all))) An array of automatic pointers, and they also cram in an object created dynamically.
Finally!))
It's the object that must be placed in the object array element.
In the first case - you have exactly an array of objects, what "pointers"?
That's my point ! Why does it WORK?!
Finally!))
That's my point! Why does it WORK?!
If A is declared so:
A* m_A[2];
Then it's OK.
And if it's like this:
A m_A[2];
It shouldn't compile. Either there is a bug in the compiler, or the compiler doesn't have to think for everyone.
Then it shouldn't compile. Either there's a bug in the compiler, or the compiler doesn't have to think for everyone.
Bingo!