Semantically
of(args)
coincides with
f(o, args)
So you can consider the function you are calling ( A::foo() ) so that it is equivalent:
void A_foo(A* pthis) { cout << "Work"; }
As you can see, pthis never dereferenced, so there is no invalid memory access. Even if you type this->foo() , this is exactly the same call, and this does not need to be dereferenced.
At least this is one of the common ways to implement a compiler. This is undefined as to what might happen, so running the code on Death Station 9000 can lead the kitten into space instead. Think about kittens!
source share