This sentence is true: in a (standard) C ++ program, or rather a process, it has exactly one address space. So, as ulidtko pointed out, this proposal relates to the possibilities of exchanging pointers to virtual and non-virtual member functions between the address spaces of different processes.
A non-virtual member function of a class is pretty much a standard function with an implicit argument for the object you are calling it for (this pointer). Thus, when loading it is assigned some address in the address space of your process. Where exactly this ends in your address space, of course, depends on your platform and whether this member function is part of a dynamically linked library. The fact is that for two processes this is not necessarily the same address. Thus, passing a pointer to and then executing such a function in another process will potentially "bring your machine to work (TM)."
A virtual member function is still almost the same as a non-virtual member function, as in "some memory address to which you go to execution and pass this pointer to it", but it receives a call through the virtual function table ( vtable) instead of direct. Thus, a pointer to a virtual member function is just an index in your object virtual function table. Calling this function does something in accordance with โtaking a pointer to an objectโ, possibly increasing the pointer to go to the vtable object and go to the address at the specified index of this table, passing the address of the object itself as this pointer. โThus, this indirect use via vtable allows you to exchange a pointer to a virtual member function between address spaces.
Disclaimer: I am slightly leaning over my "I really know what I'm talking about" - there is a comfort zone here. Therefore, if I have simplified something or something else, however, while distributing false information, do not hesitate to drop my answer;).
source share