In a function, how to you assign this a new value?
You can't.
1 In the body of a non-static (9.3) member function, the keyword
thisis a prvalue expression whose value is the address of the object for which the function is called. [...] (emphasis & link mine)
You can modify the object this points to, which is *this. For example:
struct X
{
int x;
void foo()
{
this->x =3;
}
};
The method modifies the object itself, but something like this = new X is illegal.