Is `this` pointer assignable in c++?

102 Views Asked by At

when I try to assign a pointer to this pointer, My IDE(clion) said Expression is not assignable. So, Is this pointer assignable in c++ ? Is it a rvalue?

1

There are 1 best solutions below

0
mediocrevegetable1 On

Yes, this is an rvalue. Specifically, it's a prvalue:

The keyword this is a prvalue expression whose value is the address of the implicit object parameter (object on which the non-static member function is being called).

(From https://en.cppreference.com/w/cpp/language/this)

Hence, this is not assignable.