How can you assign a value to the pointer ‘this’ in C++

You can assign the object this points at:

*this = XY;

But you can’t assign the direct value of this:

this = &XY;   // Error: Expression is not assignable

Leave a Comment