Oops, I'm slowing down, the second example isn't right at all.
That's why it is logical that
error: invalid initialization of non-const reference of type 'int*&' from an rvalue of type 'int*'
Yes, I already wrote about it above. I modified the second sample but it still does not work. The operator returns a value, i.e. a copy. All three of us must have got so obtuse, eh! ))
Комбинатор: So why does the first piece of fxsaber example work then?
Why shouldn't he? He has an expression this[0] that returns a pointer. Here is the same thing in a different form:
int a;
int* Func(int& i)
{
return(&i);
}
int* p = Func(a); // работает, то же что A* a = this[0]
Func(a) = newint; // не работает, то же, что и this[0] = new int
Комбинатор: The problem is that the pointer (descriptor) from rvalue somehow turns into lvalue after being assigned to a variable. That's a bit crazy...
Yes it's me who is confused. After
A* a = this[0];
a = new A; // так работает
The expression
CheckPointer(this[0]) == POINTER_INVALID
will be true. Which makes perfect sense.
The developers should formulate the reason why it is impossible clearly and nicely
I still don't understand the last example. Overloading "=" operator in class A turns this[0] from rvalue into lvalue... I can't figure out how. Is this some kind of MCL feature, there's no such behaviour in the pros.fxsaber, how did you even get to this construct? I mean overload = in A. Or by trial and error?
Oops, I'm slowing down, the second example isn't right at all.
That's why it is logical that
error: invalid initialization of non-const reference of type 'int*&' from an rvalue of type 'int*'
All three of us had to be so dumb, eh! ))
So why does the first piece of fxsaber example work then?
Why shouldn't he? He has an expression this[0] that returns a pointer. Here is the same thing in a different form:
this[0] is rvalue here.
Result The problem is some nonsense. Unfortunately, the vocabulary is scarce to explain it.
fxsaber:
Точно не так
Результат
The problem is a certain pointlessness
Unfortunately, the vocabulary is scarce for explanation.OK, I don't feel like thinking. Tired already.
The problem is that the pointer (descriptor) from rvalue somehow turns into lvalue after being assigned to a variable. That's a bit crazy...
The expression
will be true. Which makes perfect sense.
The developers should formulate the reason why it is impossible clearly and nicely
Yeah, I messed up.
In short, it's all good :)